import { guid, getHump, focusInput } from '@/util/helpers';
// import layer from 'layui-layer';
// import $ from 'jquery';
// import 'bootstrap/dist/css/bootstrap.min.css'; //前面因为版本问题无法使用,后面执行npm install bootstrap,成功
// import 'bootstrap/dist/js/bootstrap.min.js';
import { DefaultStationUiData } from './mock-stationui-design'; //工站默认UI设计

import { stationIcon } from './station-icon'; //工站图标
import { DefaultFunctionUiData } from './mock-functionui-design'; //默认功能UI设计--不要
import { ComponentList } from './mock-stationui-component'; //组件库
import CommonModalTemplate from '@/components/common-modal-template/common-modal-template';
import { Base64 } from 'js-base64';
import { getToken } from '@/util/auth';
import website from '@/config/website';
import {
  getWorkStationDetail,
  SaveStationuiDesignApi,
  getWorkStationTemplateDetail,
  SaveStationuiTemplateDesign,
  getWorkStationTemplateSelect,
  getVehicleTypeSelect
} from '@/api/product/station-manage';
export default {
  components: {
    CommonModalTemplate
  },
  props: ['stationuiDialogVisible', 'uiConfig'],
  data() {
    //初始数据加载书写
    return {
      showEditDialog: false,
      type: 'station', //记录的类型--STATION工站、FUNCTION功能(产品重构已经不再使用功能设计,可全部去除)
      dialogInfo: {
        zhCnName: '',
        clientType: 'WEB'
      }, //工站的信息
      ComponentList: ComponentList, //拖拽组件数据信息
      stationUiTemplateList: [], //工序模版下拉数据
      stationuiType: '', //UI界面默认类型
      activeName: 'TabsstationInfoConfig', //右侧工站基本信息显示TabsstationInfoConfig
      dragItemInfo: 'dragItemInfoConfig', //右侧组件基本信息显示Tabs
      stationTypeList: [
        //工站类型集合
        {
          code: 'OVERSTATION',
          name: '过站'
        },
        {
          code: 'TIMESHEET',
          name: '报工'
        },
        {
          code: 'TEST',
          name: '测试'
        },
        {
          code: 'AGING',
          name: '老化'
        },
        {
          code: 'PACKING',
          name: '包装'
        },
        {
          code: 'ASSEMBLY',
          name: '组装'
        },
        {
          code: 'FEEDING',
          name: '上料'
        }
      ],

      dialogModel: {
        //每个节点的信息
        // dataType: 'input'
      },
      stationInitRequestList: [], //工站初始化加载API
      selectedNodeActionList: [], //每个节点的动作信息
      stationUiList: [], //整个UI界面每个节点对应的信息
      selectOption: [],
      inputComList: [], //整个UI界面所有输入框

      modalName: '',
      timer: new Date().getTime(),
      tableOption: {}, //公用模态框表格属性
      responseType: 0, //添加响应的类型
      responseIndex: 'station', //添加响应的索引

      requestItemIndex: 0, //当前编辑的响应(API参数)的索引
      requestItemType: 'station', //当前编辑的响应(API参数)的类型 工站初始加载、组件响应

      showApiDialog: false, //API参数信息弹框
      dialogTitle: 'API参数信息设置',
      afterIndex: -1,
      dataApiParamsMap: [], //API参数信息列表

      //API参数信息编辑
      apiParamsOption: {
        height: 'calc(100vh - 500px)',
        calcHeight: 30,
        border: true,
        index: true,
        selection: true,
        addBtn: false,
        viewBtn: false,
        addRowBtn: true,
        cellBtn: true,
        columnBtn: false,
        refreshBtn: false,
        tip: false,
        column: [
          {
            label: '参数字段',
            prop: 'code',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '参数默认值',
            prop: 'name',
            cell: true
          },
          {
            label: '映射字段',
            prop: 'mapingCode',
            cell: true
          }
        ]
      },
      showApiResponseModal: false, //API返回信息配置模态框是否显示
      apiResponseTabsIndex: '1',
      successDoParamsMap: [], //API返回成功信息
      successDoParamsOption: {
        //API返回成功信息表格配置
        height: 'calc(100vh - 500px)',
        calcHeight: 30,
        border: true,
        index: true,
        selection: true,
        addBtn: false,
        viewBtn: false,
        addRowBtn: true,
        cellBtn: true,
        columnBtn: false,
        refreshBtn: false,
        tip: false,
        column: [
          {
            label: '组件字段名称',
            prop: 'componentField',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: 'API返回字段名称',
            prop: 'apiField',
            cell: true //编辑的字段设置cell为true
          }
        ]
      },
      failDoParamsMap: [], //API返回失败信息
      failDoParamsOption: {
        //API返回失败信息表格配置
        height: 'calc(100vh - 500px)',
        calcHeight: 30,
        border: true,
        index: true,
        selection: true,
        addBtn: false,
        viewBtn: false,
        addRowBtn: true,
        cellBtn: true,
        columnBtn: false,
        refreshBtn: false,
        tip: false,
        column: [
          {
            label: '组件字段名称',
            prop: 'componentField',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: 'API返回字段名称',
            prop: 'apiField',
            cell: true //编辑的字段设置cell为true
          }
        ]
      },
      showColumnConfigModal: false, //编辑列信息模态框是否显示
      columnConfig: [], //编辑列信息
      columnConfigOption: {
        //编辑列信息表格配置
        height: 'calc(100vh - 500px)',
        calcHeight: 30,
        border: true,
        index: true,
        selection: true,
        addBtn: false,
        viewBtn: false,
        addRowBtn: true,
        cellBtn: true,
        columnBtn: false,
        refreshBtn: false,
        tip: false,
        column: [
          {
            label: '显示名称',
            prop: 'headerName',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '字段',
            prop: 'field',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '序号',
            prop: 'sequence',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '自定义模版',
            prop: 'cellRenderer',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '是否去重',
            prop: 'isVerifyDuplicate',
            type: 'select',
            dicData: [
              { label: '是', value: true },
              { label: '否', value: false }
            ],
            cell: true //编辑的字段设置cell为true
          }
        ]
      },
      showModalColumnConfigModal: false, //弹窗列表编辑列信息模态框是否显示
      modalColumnConfig: [], //弹窗列表编辑列信息
      showIconImgDialog: false, //图标选择模态框是否显示
      stationIconList: stationIcon(),
      vehicleTypeList: [], //载具类型
      showExtendedFieldsModal: false, //扩展字段设置信息是否显示
      extendedFieldsConfig: [],
      extendedFieldsConfigOption: {
        height: 'calc(100vh - 500px)',
        calcHeight: 30,
        border: true,
        index: false,
        selection: true,
        addBtn: false,
        viewBtn: false,
        addRowBtn: true,
        cellBtn: true,
        columnBtn: false,
        refreshBtn: false,
        tip: false,
        column: [
          {
            label: '序号',
            prop: 'sequence',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '扩展属性名称',
            prop: 'headerName',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '扩展属性字段',
            prop: 'field',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '扩展类型',
            prop: 'type',
            type: 'select',
            dicData: [
              { label: '文本框', value: 'text' },
              { label: '下拉框', value: 'select' }
            ],
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '数据源',
            prop: 'dataSource',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '跳转输入框',
            prop: 'turnToInputName',
            type: 'select',
            dicData: [],
            cell: true, //编辑的字段设置cell为true
            click: (val) => {
              let inputComList = [];
              inputComList = this._map(this.stationUiList, (item) => {
                let selectedNodeDataType = this._get(item, 'cfModelAttribute.dataType', '');
                if (
                  selectedNodeDataType === 'input' ||
                  selectedNodeDataType === 'textarea' ||
                  selectedNodeDataType === 'vehicle' ||
                  (selectedNodeDataType === 'select-data' && item.cfModelAttribute.isDisabled === 'false')
                ) {
                  return {
                    label: this._get(item, 'cfModelAttribute.labelName', ''),
                    value: this._get(item, 'cfModelAttribute.field', '')
                  };
                }
              });
              inputComList = this._compact(inputComList);
              this._forEach(this.dialogModel.extendedFieldsConfig, (item) => {
                if (item.headerName && item.field) {
                  inputComList.push({ label: item.headerName, value: item.field });
                }
              });
              let turnToInputName = this.findObject(this.extendedFieldsConfigOption.column, 'turnToInputName');
              turnToInputName.dicData = inputComList;
            }
          }
        ]
      },
      showAttributeCopyModal: false,
      selectDataTypeList: [
        {
          label: '不良现象',
          value: 'failure'
        },
        {
          label: '包规数量',
          value: 'standardQuantity'
        },
        {
          label: '打印机',
          value: 'print'
        },
        {
          label: '打印模版',
          value: 'labelTemplate'
        },
        {
          label: '序列号规则',
          value: 'sequenceDefine'
        },
        {
          label: '维修代码',
          value: 'maintenanceCode'
        }
      ], //数据选择框组件配置选择数据类型
      selectDataType: '', //选择数据类型
      showRecordItemModal: false, //记录项配置模态框是否显示
      recordItemConfig: [], //记录项内容
      recordItemConfigOption: {
        //记录项配置属性
        height: 'calc(100vh - 500px)',
        calcHeight: 30,
        border: true,
        index: false,
        selection: true,
        addBtn: false,
        viewBtn: false,
        addRowBtn: true,
        cellBtn: true,
        columnBtn: false,
        refreshBtn: false,
        tip: false,
        column: [
          {
            label: '序号',
            prop: 'sequence',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '记录项名称',
            prop: 'headerName',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '记录项字段',
            prop: 'headerFile',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '是否必填',
            prop: 'isRequired',
            type: 'select',
            dicData: [
              {
                label: '是',
                value: true
              },
              {
                label: '否',
                value: false
              }
            ],
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '跳转输入框',
            prop: 'turnToInputName',
            type: 'select',
            dicData: [],
            cell: true, //编辑的字段设置cell为true
            click: (val) => {
              let inputComList = [];
              inputComList = this._map(this.stationUiList, (item) => {
                let selectedNodeDataType = this._get(item, 'cfModelAttribute.dataType', '');
                if (
                  selectedNodeDataType === 'input' ||
                  selectedNodeDataType === 'textarea' ||
                  selectedNodeDataType === 'vehicle' ||
                  (selectedNodeDataType === 'select-data' && item.cfModelAttribute.isDisabled === 'false')
                ) {
                  return {
                    label: this._get(item, 'cfModelAttribute.labelName', ''),
                    value: this._get(item, 'cfModelAttribute.field', '')
                  };
                }
              });
              inputComList = this._compact(inputComList);
              this._forEach(this.dialogModel.recordItemConfig, (item) => {
                if (item.headerName && item.headerFile) {
                  inputComList.push({ label: item.headerName, value: item.headerFile });
                }
              });
              let turnToInputName = this.findObject(this.recordItemConfigOption.column, 'turnToInputName');
              turnToInputName.dicData = inputComList;
            }
          }
        ]
      },
      designerItem: {},
      containerRatio: '',
      disabledInputComList: [],
      displayOrHideModulesList: [],
      showChartSourceResponseModal: false,
      chartSourceParamsMap: [],
      chartSourceParamsOption: {
        //API返回成功信息表格配置
        height: 'calc(100vh - 500px)',
        calcHeight: 30,
        border: true,
        index: true,
        selection: true,
        addBtn: false,
        viewBtn: false,
        addRowBtn: true,
        cellBtn: true,
        columnBtn: false,
        refreshBtn: false,
        tip: false,
        column: [
          {
            label: '参数字段',
            prop: 'code',
            cell: true //编辑的字段设置cell为true
          },
          {
            label: '参数默认值',
            prop: 'defaultValue',
            cell: true
          },
          {
            label: '映射字段',
            prop: 'mapingCode',
            cell: true
          }
        ]
      },
      chartSourceIndex: '',
      showBeforeRequestModal: false,
      beforeRequestData: [],
      beforeRequestOption: {
        height: '500',
        calcHeight: 30,
        border: true,
        index: true,
        selection: true,
        addBtn: false,
        viewBtn: false,
        addRowBtn: true,
        cellBtn: true,
        columnBtn: false,
        refreshBtn: false,
        tip: false,
        column: [
          {
            label: '字段名称',
            prop: 'name',
            cell: true,
            rules: [
              {
                required: true,
                message: '请选择字段名称',
                trigger: 'submit'
              }
            ]
          },
          {
            label: '字段编码',
            prop: 'code',
            cell: true,
            rules: [
              {
                required: true,
                message: '请选择字段编码',
                trigger: 'submit'
              }
            ]
          },
          {
            label: '默认值',
            prop: 'defaultValue',
            cell: true
          },
          {
            label: '是否禁用',
            prop: 'isDisabled',
            type: 'select',
            dicData: [
              { label: '是', value: true },
              { label: '否', value: false }
            ],
            cell: true
          },
          {
            label: '是否必填',
            prop: 'isReqired',
            type: 'select',
            dicData: [
              { label: '是', value: true },
              { label: '否', value: false }
            ],
            cell: true
          },
          {
            label: '是否回车提交',
            prop: 'isEnterSubmit',
            type: 'select',
            dicData: [
              { label: '是', value: true },
              { label: '否', value: false }
            ],
            cell: true
          }
        ]
      }
    };
  },
  watch: {
    stationuiDialogVisible(val) {
      if (val) {
        this.showEditDialog = true;
        setTimeout(() => {
          /**
           * 左侧控件Li点击事件，转移激活状态
           */
          $('.palette-list').on('click', 'li', (event) => {
            let $li = $(event.target).parents('li');
            $li.parents('.palette-list').find('li').removeClass('active');
            $li.addClass('active');
          });

          /**
           * 设计框中每一个节点的点击事件，转移激活状态以及获取当前点击的节点信息
           */
          $('.designer-box .dialog-div').on('click', (event) => {
            this.dragItemInfo = 'dragItemInfoConfig';
            let isDragItem = $(event.target).hasClass('drag-item');
            let isDragItemChild = $(event.target).closest('.drag-item').hasClass('drag-item');
            //点击了拖拽节点以及拖拽节点中的元素
            if (isDragItem || isDragItemChild) {
              let $dragItem = $(event.target);
              console.log($dragItem);
              if (!$dragItem.hasClass('drag-item')) {
                $dragItem = $(event.target).closest('.drag-item');
              }
              //先将设计框中所有item的激活状态都移除
              $('.drag-item').removeClass('active');
              $('.drag-item').removeClass('error');

              $dragItem.addClass('active');
              $('.col_content').removeClass('active');
              $dragItem.parents('.col_content').addClass('active');

              let id = $dragItem.attr('id');
              this.setModelValue(id);
            } else {
              this.activeName = 'TabsstationInfoConfig';
              $('.drag-item').removeClass('active');

              this.dialogModel = {};
              this.selectOption = [];
              this.selectedNodeActionList = [
                {
                  actionType: this.dialogModel.actionType,
                  commonDataList: []
                }
              ];
            }
            console.log(this.dialogModel);
          });

          /**
           * 移除事件拖拽节点
           */
          $('.dialog-div').on('click', '.closer', (event) => {
            //判断是否删除容器，根据容器上的Class来判断
            let hasClass = $(event.target).next().hasClass('designer-item');
            if (hasClass) {
              this.$confirm('是否删除该容器下所有组件?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              })
                .then(() => {
                  let $col_content = $(event.target).parents('.col_content');
                  let $dragItem = $col_content.find('.drag-item');
                  //删除容器下所有拖拽节点
                  let col_content_dragItemIds = [];
                  $dragItem.each((index, item) => {
                    col_content_dragItemIds.push($(item).attr('id'));
                  });
                  //过滤数据
                  this.stationUiList = this._filter(this.stationUiList, (item, index) => {
                    if (this._indexOf(col_content_dragItemIds, item.cfModelAttribute.id) > -1) {
                      return false;
                    } else {
                      return true;
                    }
                  });
                  $col_content.remove();
                  this.dialogModel = {};
                  this.selectedNodeActionList = [];
                  this.$message({
                    type: 'success',
                    message: '删除成功!'
                  });
                })
                .catch(() => {
                  this.$message({
                    type: 'info',
                    message: '已取消删除'
                  });
                });
              // layer.confirm('是否删除该容器下所有组件？', {
              //     title: '提示',
              //     offset: '200px',
              //     shadeClose: true,
              //     btn: ['取消', '确定']
              // }, (index) => {
              //     layer.close(index);
              // }, (index) => {
              //     let $col_content = $(event.target).parents('.col_content');
              //     let $dragItem = $col_content.find('.drag-item');
              //     //删除容器下所有拖拽节点
              //     let col_content_dragItemIds = [];
              //     $dragItem.each((index, item) => {
              //         col_content_dragItemIds.push($(item).attr('id'));
              //     });
              //     //过滤数据
              //     this.stationUiList = this._filter(this.stationUiList, (item, index) => {
              //         if (this._indexOf(col_content_dragItemIds, item.cfModelAttribute.id) > -1) {
              //             return false;
              //         } else {
              //             return true;
              //         }
              //     });
              //     $col_content.remove();
              //     this.dialogModel = {};
              //     this.selectedNodeActionList = [];
              // });
            } else {
              this.$confirm('是否删除该组件?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              })
                .then(() => {
                  let $dragItem = $(event.target).closest('.drag-item');
                  let $dragItemRemoveId = $dragItem.attr('id');
                  //删除节点并移除数据
                  $dragItem.remove();
                  let removeDragItemIndex = this._findIndex(this.stationUiList, (item) => {
                    if ($dragItemRemoveId === item.cfModelAttribute.id) {
                      return true;
                    }
                  });
                  this.stationUiList.splice(removeDragItemIndex, 1);
                  this.dialogModel = {};
                  this.selectedNodeActionList = [];
                  this.$message({
                    type: 'success',
                    message: '删除成功!'
                  });
                })
                .catch(() => {
                  this.$message({
                    type: 'info',
                    message: '已取消删除'
                  });
                });
            }
            event.stopPropagation();
          });

          /**
           * 检验报告中td点击事件
           */
          $('.designer-box .dialog-div').on('click', '.table-report td', (event) => {
            let tagName = $(event.target).get(0).tagName;
            $('.table-report').find('td').removeClass('tdActive');
            let $currentDom = $(event.target);
            if (tagName !== 'TD') {
              $currentDom = $(event.target).parents('td');
            }
            $currentDom.addClass('tdActive');
            this.dialogModel.rowspanLenth = $currentDom.attr('rowspan') ? $currentDom.attr('rowspan') : 1;
            this.dialogModel.colspanLenth = $currentDom.attr('colspan') ? $currentDom.attr('colspan') : 1;
            let tdFontSize = $currentDom.css('font-size');
            if (tdFontSize) {
              this.dialogModel.tdFontSize = tdFontSize.substr(0, tdFontSize.length - 2);
            } else {
              this.dialogModel.tdFontSize = '';
            }

            let tdLineHeight = $currentDom.css('line-height');
            if (tdLineHeight) {
              this.dialogModel.tdLineHeight = tdLineHeight.substr(0, tdLineHeight.length - 2);
            } else {
              this.dialogModel.tdLineHeight = '';
            }

            let tdWidth = $currentDom.css('width');
            if (tdWidth) {
              this.dialogModel.tdWidth = tdWidth.substr(0, tdWidth.length - 2);
            } else {
              this.dialogModel.tdWidth = '';
            }

            this.dialogModel.tdName = $currentDom.attr('data-name') ? $currentDom.attr('data-name') : '';
            this.dialogModel.trName = $currentDom.parents('tr').attr('data-name') ? $currentDom.parents('tr').attr('data-name') : '';
          });

          /**
           * 检验报告中td双击事件
           */
          $('.designer-box .dialog-div').dblclick((event) => {
            let tagName = $(event.target).get(0).tagName;
            if (tagName === 'TD') {
              //将TD中的值放置输入框中进行修改
              let tdVal = $(event.target).text();
              $(event.target).html('');
              $(event.target).append(`<input class="input-control" type="text" name="text001" autocomplete="off" value=${tdVal}>`);
              setTimeout(() => {
                $(event.target).find('.input-control').select();
              }, 80);
            } else if (tagName === 'INPUT') {
              let inputVal = $(event.target).val();
              $(event.target).parents('td').html(inputVal);
            }
          });

          /**
           * 检验报告中输入框回车事件
           */
          $('.designer-box .dialog-div').keypress((event) => {
            let isInputControl = $(event.target).hasClass('input-control');
            if (isInputControl && event.keyCode === 13) {
              let inputVal = $(event.target).val();
              $(event.target).parents('td').html(inputVal);
            }
          });
          getVehicleTypeSelect('carrier_type').then((res) => {
            this.vehicleTypeList = this._map(res.data.data, (item) => {
              return { dictKey: item.dictKey, dictValue: item.dictValue };
            });
          });
          this.getStationInfo();
        }, 500);
      } else {
        this.showEditDialog = false;
      }
    }
  },
  computed: {
    headersObj() {
      let header = { Authorization: `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}` };
      header['Blade-Auth'] = 'bearer ' + getToken();
      return header;
    }
  },
  mounted() {},
  methods: {
    /**
     * 通过工站ID查询工站信息
     * @param stationId
     */
    getStationInfo(stationId) {
      console.log(this.uiConfig);
      this.dialogInfo = this.uiConfig;
      this.$set(this.dialogInfo, 'zhCnName', this.dialogInfo.name);
      this.$set(this.dialogInfo, 'stationType', this.dialogInfo.type);
      this.$set(this.dialogInfo, 'zhCnContent', this.dialogInfo.remark);
      let dialogInfo = this._find(this.stationTypeList, { code: this.dialogInfo.stationType });
      this.$set(this.dialogInfo, 'stationTypeName', this._get(dialogInfo, 'name', ''));

      //工站初始加载信息
      let stationOption = this._get(this.dialogInfo, 'options', '');
      let stationInitRequestList = stationOption ? this._get(JSON.parse(stationOption), 'initRequestList', []) : [];
      // 先判断stationInitRequestList里的序号是否赋值，若无赋值则显示空
      this.stationInitRequestList = this._map(stationInitRequestList, (commonDataItem) => {
        if (!commonDataItem.sequence) {
          commonDataItem.sequence = '';
        }
        return commonDataItem;
      });
      // this.dialogInfo.initInputName = stationOption ? this._get(JSON.parse(stationOption), 'initInputName', '') : '';
      this.$set(this.dialogInfo, 'initInputName', stationOption ? this._get(JSON.parse(stationOption), 'initInputName', '') : '');

      //工站UI设计html信息以及数据信息
      let stationUiPage = this._get(this.dialogInfo, 'uiPage', '');
      let stationUiJson = this._get(this.dialogInfo, 'uiJson', '');
      this.stationUiList = stationUiJson ? JSON.parse(stationUiJson) : [];
      this.dialogModel = {};
      this.selectOption = [];
      this.selectedNodeActionList = [];
      this.showStationUiPage(stationUiPage);
    },

    /**
     * 通过工站模版ID查询工站信息
     * @param stationId
     */
    getStationTemplateInfo(stationId) {
      getWorkStationTemplateDetail(stationId).then((res) => {
        if (res.data) {
          this.dialogInfo = {};
          let stationTemplateInfo = res.data.data;
          this.$set(this.dialogInfo, 'clientType', stationTemplateInfo.clientType);
          this.$set(this.dialogInfo, 'zhCnName', stationTemplateInfo.name);
          this.$set(this.dialogInfo, 'stationType', stationTemplateInfo.type);
          this.$set(this.dialogInfo, 'imgsrc', stationTemplateInfo.imgsrc);
          this.$set(this.dialogInfo, 'zhCnContent', stationTemplateInfo.remark);
          let stationTypeInfo = this._find(this.stationTypeList, { code: stationTemplateInfo.stationType });
          this.$set(this.dialogInfo, 'stationTypeName', this._get(stationTypeInfo, 'name', ''));
          //工站初始加载信息
          let stationOption = this._get(stationTemplateInfo, 'options', '');
          let stationInitRequestList = stationOption ? this._get(JSON.parse(stationOption), 'initRequestList', []) : [];
          // 先判断stationInitRequestList里的序号是否赋值，若无赋值则显示空
          this.stationInitRequestList = this._map(stationInitRequestList, (commonDataItem) => {
            if (!commonDataItem.sequence) {
              commonDataItem.sequence = '';
            }
            return commonDataItem;
          });
          // this.dialogInfo.initInputName = stationOption ? this._get(JSON.parse(stationOption), 'initInputName', '') : '';
          this.$set(this.dialogInfo, 'initInputName', stationOption ? this._get(JSON.parse(stationOption), 'initInputName', '') : '');

          //工站UI设计html信息以及数据信息
          let stationUiPage = this._get(stationTemplateInfo, 'uiPage', '');
          let stationUiJson = this._get(stationTemplateInfo, 'uiJson', '');
          this.stationUiList = stationUiJson ? JSON.parse(stationUiJson) : [];
          this.dialogModel = {};
          this.selectOption = [];
          this.selectedNodeActionList = [];
          this.showStationUiPage(stationUiPage);
        } else {
          this.showStationUiPage('');
        }
      });
    },

    /**
     * 显示工站UI设计 关键代码
     * @param stationUiPageData
     */
    showStationUiPage(stationUiPageData) {
      debugger;
      console.log(stationUiPageData);
      $('.dialog-div').empty();
      $('.dialog-div').append(stationUiPageData);
      //赋值默认值
      this._forEach(this.stationUiList, (item) => {
        let selectedNodeDataType = this._get(item, 'cfModelAttribute.dataType', '');
        let selectedNodeDataId = this._get(item, 'cfModelAttribute.id', '');
        let $dragItem = $(`#${selectedNodeDataId}`);
        let dataSource = this._get(item, 'cfModelAttribute.dataSource', []);
        if (selectedNodeDataType === 'radio') {
          if (dataSource.length > 0) {
            let valueObj = this._find(dataSource, { key: this._get(item, 'cfModelAttribute.defaultValue', '') });
            let defaultValue = this._get(dataSource, '[0].key', '');
            if (valueObj) {
              $dragItem.find('input[value=' + this._get(item, 'cfModelAttribute.defaultValue', '') + ']').prop('checked', true);
            } else {
              $dragItem.find('input[value=' + defaultValue + ']').prop('checked', true);
            }
          }
        } else if (selectedNodeDataType === 'select') {
          //下拉框赋默认值
          let valueObj = this._find(dataSource, { optionField: this._get(item, 'cfModelAttribute.defaultValue', '') });
          if (valueObj) {
            $dragItem.find('select').val(this.dialogModel.defaultValue);
          } else {
            let defaultValue = this._get(dataSource, '[0].optionField', '');
            $dragItem.find('select').val(defaultValue);
          }
        }
      });
      // Helpers.selectedFirstTab('dragItemInfo');
    },

    /**
     * 拖拽过程不执行任何操作，将会被持续触发
     * @param event
     */
    dragstart(event) {
      console.log(event, '拖拽持续触发');
      event.dataTransfer.setData('Text', event.target.id);
      // event.dataTransfer.setData('type', type);用来传递拖拽时的传参，即在drop监听函数中可获取该参数信息；
    },

    /**
     * 容器接收拖拽组件事件
     * @param event
     */
    designerDivDrop(event) {
      console.log(event, '容器接收');
      //是否有栅格容器
      let isDesignerItem = $(event.target).hasClass('designer-item');
      console.log(isDesignerItem, 'isDesignerItem');
      let isDesignerItemChild = $(event.target).parents('.designer-item').hasClass('designer-item');
      let isColContent = $(event.target).hasClass('col_content');
      // console.log($(event.target));

      let dragItemId = event.dataTransfer.getData('Text'); // html页面中定义的id
      if (isDesignerItem || isDesignerItemChild) {
        let $designerItem = $(event.target);
        if (isDesignerItemChild) {
          $designerItem = $(event.target).parents('.designer-item'); // 从父元素开始沿 DOM 树向上遍历，并返回匹配所传递的表达式的所有祖先
        }
        if (
          dragItemId !== 'col_12' &&
          dragItemId !== 'col_6_6' &&
          dragItemId !== 'col_4_8' &&
          dragItemId !== 'col_4_4_4' &&
          dragItemId !== 'col_3_3_3_3' &&
          dragItemId !== 'col_custom'
        ) {
          //生成随机GUID
          let dragItemGuid = guid();
          let dragItemHtml = document.createElement('div');
          dragItemHtml.setAttribute('data-type', dragItemId); // 创建或改变某个新属性
          dragItemHtml.setAttribute('id', dragItemGuid);
          //通过类型查找组件库
          let componentItem = this._find(this.ComponentList, {
            type: dragItemId
          });
          if (componentItem) {
            dragItemHtml.setAttribute('class', this._get(componentItem, 'class', ''));
            dragItemHtml.innerHTML = this._get(componentItem, 'innerHTML', '');

            if (isDesignerItemChild) {
              if (event.target.tagName === 'TD') {
                // 在被选元素前插入 HTML 元素
                event.target.insertBefore(dragItemHtml, this.children(event.target)[this.count]);
              } else {
                $designerItem[0].insertBefore(dragItemHtml, this.children($designerItem[0])[this.count]);
              }
            } else {
              event.target.insertBefore(dragItemHtml, this.children(event.target)[this.count]);
            }

            //将所有拖拽节点移除Class激活状态，将当前拖拽节点激活
            $('.dialog-div .drag-item').removeClass('active');
            $('#' + dragItemGuid).addClass('active');

            $('.col_content').removeClass('active');
            $('#' + dragItemGuid)
              .parents('.col_content')
              .addClass('active');

            //将拖拽出来的节点赋值以及放进数组中
            let dataType = $(dragItemHtml).attr('data-type'); // 向被选元素添加一个或多个类
            let labelName = $(dragItemHtml).find('.drag-item-text').text();
            let field = $(dragItemHtml).find('input').attr('name');
            let iconClass = $(dragItemHtml).find('.card .fa').attr('class');
            let placeholder = `请输入`;
            if (dataType === 'select') {
              field = $(dragItemHtml).find('select').attr('name');
            }
            if (dataType === 'textarea') {
              field = $(dragItemHtml).find('textarea').attr('name');
            }
            if (dataType === 'multiple-print') {
              field = 'extraPrint';
            }
            let backgroundColor = '';
            if (dataType === 'card') {
              backgroundColor = $(dragItemHtml).find('.card i').css('background');
            } else if (dataType === 'button') {
              backgroundColor = $(dragItemHtml).find('button').css('background');
            }

            let fontColor = '';
            if (dataType === 'card') {
              fontColor = $(dragItemHtml).find('.card .fa').css('color');
            } else if (dataType === 'border-title') {
              fontColor = $(dragItemHtml).find('.border-title').css('color');
            }

            let fontSize = '';
            if (dataType === 'border-title') {
              fontSize = $(dragItemHtml).find('.border-title').css('font-size');
              fontSize = fontSize.substr(0, fontSize.length - 2);
            }
            let tbodyHeight = $(dragItemHtml).find('tbody').height();

            let pictureUrl = '';
            if (dataType === 'picture') {
              pictureUrl = $(dragItemHtml).find('img').attr('src');
            }

            let checkStepList = [];
            let actionType = '';
            switch (dataType) {
              case 'input':
                actionType = 'enter';
                break;
              case 'button':
                actionType = 'click';
                break;
              case 'select':
                actionType = 'change';
                break;

              default:
                break;
            }
            this.dialogModel = {
              id: dragItemGuid,
              field: field,
              dataType: dataType,
              labelName: labelName,
              placeholder: placeholder,
              defaultTipMessage: '',
              inputType: 'text',
              defaultValue: '',
              regexp: '',
              vehicleType: '',
              vehicleTypeField: '',
              optionField: '',
              optionText: '',
              turnToInputName: '',
              failTurnToInputName: '',
              turnToExpression: '',
              noApiTurnToInputName: '',
              backgroundColor: backgroundColor,
              fontColor: fontColor,
              fontSize: fontSize,
              iconClass: iconClass,
              isRequired: 'false',
              isDisabled: dataType === 'select-data' ? 'true' : 'false',
              isAutoDeduction: false,
              dataSource: [],
              tableHeight: tbodyHeight,
              rowspanLenth: 1,
              colspanLenth: 1,
              pictureUrl: pictureUrl,
              checkStepApiId: '',
              checkStepApiName: '',
              checkStepList: checkStepList,
              columnDefs: [],
              modalColumnDefs: [],
              actionType: actionType,
              extendedFieldsConfig: [],
              recordItemConfig: [],
              selectDataType: '',
              isLocalStorage: false,
              disabledInputName: '',
              createQrCode: '',
              noApiTurnToInputIsMsg: false,
              isHideModule: false,
              displayOrHideModules: '',
              defaultSelectDataCode: '',
              defaultSelectDataName: '',
              isSupportMixPack: false,
              mixPackField: '',
              optionListApi: '',
              optionListApiCode: '',
              dataSourceRequestParam: '',
              dataSourceFormat: '',
              chartHeight: 350,
              chartSourceList: [],
              beforeRequestData: [],
              hideFormItemList: [],
              isDefaultHide: false,
              isEnableCache: false,
              isTogetherVerifyDuplicate: false,
              isCachePrintInfo: false
            };
            // Helpers.selectedFirstTab('dragItemInfo');

            let cfModelAttribute = {};
            for (const key in this.dialogModel) {
              if (Object.prototype.hasOwnProperty.call(this.dialogModel, key)) {
                const element = this.dialogModel[key];
                cfModelAttribute[key] = element;
              }
            }

            this.selectedNodeActionList = [
              {
                actionType: '',
                commonDataList: []
              }
            ];
            this.stationUiList.push({
              cfModelAttribute: cfModelAttribute,
              cfActionList: this.selectedNodeActionList
            });
          }
        }
      } else {
        if (!isColContent) {
          let divstr = '';
          switch (dragItemId) {
            case 'col_12':
              divstr = `<div class="col_content" data-type="col_12">
                      <i class="el-icon-circle-close closer"></i>
                      <div class="el-col-lg-24 el-col-xs-24 designer-item"></div>
                      </div>`;
              break;
            case 'col_6_6':
              divstr = `<div class="col_content" data-type="col_6_6">
                          <i class="el-icon-circle-close closer"></i>
                          <div class="el-col-lg-12 el-col-xs-12 designer-item"></div>
                          <div class="el-col-lg-12 el-col-xs-12 designer-item"></div>
                          </div>`;
              break;
            case 'col_4_8':
              divstr = `<div class="col_content" data-type="col_4_8">
                          <i class="el-icon-circle-close closer"></i>
                          <div class="el-col-lg-8 el-col-xs-8 designer-item"></div>
                          <div class="el-col-lg-16 el-col-xs-16 designer-item"></div>
                          </div>`;
              break;
            case 'col_4_4_4':
              divstr = `<div class="col_content" data-type="col_4_4_4">
                      <i class="el-icon-circle-close closer"></i>
                      <div class="el-col-lg-8 el-col-xs-8 designer-item"></div>
                      <div class="el-col-lg-8 el-col-xs-8 designer-item"></div>
                      <div class="el-col-lg-8 el-col-xs-8 designer-item"></div>
                      </div>`;
              break;
            case 'col_3_3_3_3':
              divstr = `<div class="col_content" data-type="col_3_3_3_3">
                          <i class="el-icon-circle-close closer"></i>
                          <div class="el-col-lg-6 el-col-xs-6 designer-item"></div>
                          <div class="el-col-lg-6 el-col-xs-6 designer-item"></div>
                          <div class="el-col-lg-6 el-col-xs-6 designer-item"></div>
                          <div class="el-col-lg-6 el-col-xs-6 designer-item"></div>
                          </div>`;
              break;
            // case 'col_custom':
            //     layer.prompt(
            //         {
            //             title: '请输入布局栅格(例:1-2-3-6)'
            //             // skin: "cus-prompt-layer",
            //             // area: ['800px', '350px'] //自定义文本域宽高
            //         },
            //         function (value, index) {
            //             if (value.indexOf('-') !== -1) {
            //                 console.log(value); //得到value
            //                 let coDesignerItem = '';
            //                 let colMumberList = value.split('-');
            //                 this._forEach(colMumberList, (colItem) => {
            //                     colItem = Number(colItem);
            //                     if (!isNaN(colItem)) {
            //                         coDesignerItem += `<div class="col-lg-${colItem} col-xs-${colItem} designer-item"></div>`;
            //                     }
            //                 });
            //                 divstr = `<div class="col_content" data-type="col_custom">
            //           <i class="el-icon-circle-close closer"></i>
            //           ${coDesignerItem}
            //           </div>`;
            //                 $(event.target).append(divstr);
            //                 $('.drag-item').removeClass('active');
            //                 $('.col_content').removeClass('active');
            //                 let $length = $(event.target).find('.col_content').length;
            //                 $(event.target)
            //                     .find('.col_content')
            //                     .eq($length - 1)
            //                     .addClass('active');
            //                 layer.close(index);
            //             } else {
            //                 this.$message.error('请使用符号 - 拼接数字');
            //             }
            //         }
            //     );
            //     break;
            default:
              this.$alert('请先拖拽出布局容器!', '提示', {
                confirmButtonText: '确定',
                type: 'warning',
                callback: (action) => {}
              });
              break;
          }
          if (
            dragItemId === 'col_12' ||
            dragItemId === 'col_6_6' ||
            dragItemId === 'col_4_8' ||
            dragItemId === 'col_4_4_4' ||
            dragItemId === 'col_3_3_3_3' ||
            dragItemId === 'col_custom'
          ) {
            $(event.target).append(divstr);
            console.log(event.target, 'event.target');
            $('.drag-item').removeClass('active');
            $('.col_content').removeClass('active');
            let $length = $(event.target).find('.col_content').length;
            $(event.target)
              .find('.col_content')
              .eq($length - 1)
              .addClass('active');
          }
        }
      }
      event.preventDefault();
      event.stopPropagation();
    },

    children(node) {
      var tmp = node.childNodes;
      var arr = [];
      tmp.forEach(function (item) {
        if (item.nodeType == 1) {
          arr.push(item);
        }
      });
      return arr;
    },

    designerDivAllowDrop(event) {
      let isDesignerDiv = $(event.target).hasClass('dialog-div');
      let isDesignerItem = $(event.target).hasClass('designer-item');
      let isColContent = $(event.target).hasClass('col_content');
      let offsetTop;
      if (isDesignerDiv) {
        offsetTop = event.target.offsetTop;
      } else {
        if (isDesignerItem) {
          offsetTop = $(event.target).offset().top;
        } else {
          if (!isColContent) {
            offsetTop = $(event.target).parents('.designer-item').offset().top;
          }
        }
      }
      let clientY = event.clientY;
      this.count = Math.round((clientY - offsetTop) / 40); //40代指拖拽元素的高度
      event.preventDefault();
      event.stopPropagation();
    },

    /**
     * 选中并赋值当前组件
     * @param dragItemId
     */
    setModelValue(dragItemId) {
      this.turnToInputNameClick();
      this.getDisabledInputComList();
      let $dragItem = $(`#${dragItemId}`);
      let dataType = $dragItem.attr('data-type');
      let labelName = $dragItem.find('.drag-item-text').text();
      let field = $dragItem.find('input').attr('name');
      let iconClass = $dragItem.find('.card .fa').attr('class');
      let placeholder = `请输入${labelName}`;
      if (dataType === 'select') {
        placeholder = `请选择${labelName}`;
        field = $dragItem.find('select').attr('name');
      }
      if (dataType === 'multiple-print') {
        field = 'extraPrint';
      }
      //获取组件的背景颜色
      let backgroundColor = '';
      if (dataType === 'card') {
        backgroundColor = $dragItem.find('.card i').css('background');
      } else if (dataType === 'button') {
        backgroundColor = $dragItem.find('button').css('background');
      }

      let pictureUrl = '';
      if (dataType === 'picture') {
        pictureUrl = $dragItem.find('img').attr('src');
      }

      //获取当前选中拖拽节点的信息
      let selectedNodeInfo = this._find(this.stationUiList, (dragItem) => {
        let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
        if (dragItemGuid === dragItemId) {
          return true;
        }
      });
      console.log(selectedNodeInfo);
      this.$set(this.dialogModel, 'id', this._get(selectedNodeInfo, 'cfModelAttribute.id', dragItemId));
      this.$set(this.dialogModel, 'field', this._get(selectedNodeInfo, 'cfModelAttribute.field', field));
      this.$set(this.dialogModel, 'dataType', this._get(selectedNodeInfo, 'cfModelAttribute.dataType', dataType));
      // Helpers.selectedFirstTab('dragItemInfo');
      this.$set(this.dialogModel, 'labelName', this._get(selectedNodeInfo, 'cfModelAttribute.labelName', labelName));
      this.$set(this.dialogModel, 'placeholder', this._get(selectedNodeInfo, 'cfModelAttribute.placeholder', placeholder));
      this.$set(this.dialogModel, 'defaultTipMessage', this._get(selectedNodeInfo, 'cfModelAttribute.defaultTipMessage', ''));
      this.$set(this.dialogModel, 'inputType', this._get(selectedNodeInfo, 'cfModelAttribute.inputType', 'text'));
      this.$set(this.dialogModel, 'defaultValue', this._get(selectedNodeInfo, 'cfModelAttribute.defaultValue', ''));
      this.$set(this.dialogModel, 'regexp', this._get(selectedNodeInfo, 'cfModelAttribute.regexp', ''));
      this.$set(this.dialogModel, 'vehicleType', this._get(selectedNodeInfo, 'cfModelAttribute.vehicleType', ''));
      this.$set(this.dialogModel, 'vehicleTypeField', this._get(selectedNodeInfo, 'cfModelAttribute.vehicleTypeField', ''));
      this.$set(this.dialogModel, 'optionField', this._get(selectedNodeInfo, 'cfModelAttribute.optionField', ''));
      this.$set(this.dialogModel, 'optionText', this._get(selectedNodeInfo, 'cfModelAttribute.optionText', ''));
      this.$set(this.dialogModel, 'turnToInputName', this._get(selectedNodeInfo, 'cfModelAttribute.turnToInputName', ''));
      this.$set(this.dialogModel, 'failTurnToInputName', this._get(selectedNodeInfo, 'cfModelAttribute.failTurnToInputName', ''));
      this.$set(this.dialogModel, 'turnToExpression', this._get(selectedNodeInfo, 'cfModelAttribute.turnToExpression', ''));
      this.$set(this.dialogModel, 'noApiTurnToInputName', this._get(selectedNodeInfo, 'cfModelAttribute.noApiTurnToInputName', ''));
      this.$set(this.dialogModel, 'backgroundColor', this._get(selectedNodeInfo, 'cfModelAttribute.backgroundColor', backgroundColor));
      this.$set(this.dialogModel, 'fontColor', this._get(selectedNodeInfo, 'cfModelAttribute.fontColor', ''));
      this.$set(this.dialogModel, 'optionListApi', this._get(selectedNodeInfo, 'cfModelAttribute.optionListApi', ''));
      this.$set(this.dialogModel, 'optionListApiCode', this._get(selectedNodeInfo, 'cfModelAttribute.optionListApiCode', ''));
      this.$set(this.dialogModel, 'dataSourceRequestParam', this._get(selectedNodeInfo, 'cfModelAttribute.dataSourceRequestParam', ''));
      this.$set(this.dialogModel, 'dataSourceFormat', this._get(selectedNodeInfo, 'cfModelAttribute.dataSourceFormat', ''));
      let fontSize = '';
      if (dataType === 'border-title') {
        fontSize = $dragItem.find('.border-title').css('font-size');
        fontSize = fontSize.substr(0, fontSize.length - 2);
      }
      this.$set(this.dialogModel, 'fontSize', this._get(selectedNodeInfo, 'cfModelAttribute.fontSize', fontSize));

      this.$set(this.dialogModel, 'isRequired', this._get(selectedNodeInfo, 'cfModelAttribute.isRequired', false));
      this.$set(this.dialogModel, 'isDisabled', this._get(selectedNodeInfo, 'cfModelAttribute.isDisabled', false));
      this.$set(this.dialogModel, 'isAutoDeduction', this._get(selectedNodeInfo, 'cfModelAttribute.isAutoDeduction', false));
      this.$set(this.dialogModel, 'iconClass', this._get(selectedNodeInfo, 'cfModelAttribute.iconClass', iconClass));

      let tbodyHeight = $dragItem.find('tbody').height();
      this.$set(this.dialogModel, 'tableHeight', this._get(selectedNodeInfo, 'cfModelAttribute.tableHeight', tbodyHeight));
      this.$set(this.dialogModel, 'dataSource', this._get(selectedNodeInfo, 'cfModelAttribute.dataSource', []));
      this.$set(this.dialogModel, 'columnDefs', this._get(selectedNodeInfo, 'cfModelAttribute.columnDefs', []));
      this.$set(this.dialogModel, 'modalColumnDefs', this._get(selectedNodeInfo, 'cfModelAttribute.modalColumnDefs', []));
      this.$set(this.dialogModel, 'pictureUrl', this._get(selectedNodeInfo, 'cfModelAttribute.pictureUrl', pictureUrl));
      this.$set(this.dialogModel, 'checkStepApiId', this._get(selectedNodeInfo, 'cfModelAttribute.checkStepApiId', ''));
      this.$set(this.dialogModel, 'checkStepApiName', this._get(selectedNodeInfo, 'cfModelAttribute.checkStepApiName', ''));
      this.$set(this.dialogModel, 'checkStepList', this._get(selectedNodeInfo, 'cfModelAttribute.checkStepList', []));
      this.$set(this.dialogModel, 'extendedFieldsConfig', this._get(selectedNodeInfo, 'cfModelAttribute.extendedFields', []));
      this.$set(this.dialogModel, 'recordItemConfig', this._get(selectedNodeInfo, 'cfModelAttribute.recordItem', []));
      this.$set(this.dialogModel, 'selectDataType', this._get(selectedNodeInfo, 'cfModelAttribute.selectDataType', []));
      this.$set(this.dialogModel, 'isLocalStorage', this._get(selectedNodeInfo, 'cfModelAttribute.isLocalStorage', false));
      this.$set(this.dialogModel, 'disabledInputName', this._get(selectedNodeInfo, 'cfModelAttribute.disabledInputName', ''));
      this.$set(this.dialogModel, 'createQrCode', this._get(selectedNodeInfo, 'cfModelAttribute.createQrCode', ''));
      this.$set(this.dialogModel, 'noApiTurnToInputIsMsg', this._get(selectedNodeInfo, 'cfModelAttribute.noApiTurnToInputIsMsg', false));
      this.$set(this.dialogModel, 'isHideModule', this._get(selectedNodeInfo, 'cfModelAttribute.isHideModule', false));
      this.$set(this.dialogModel, 'displayOrHideModules', this._get(selectedNodeInfo, 'cfModelAttribute.displayOrHideModules', ''));
      this.$set(this.dialogModel, 'defaultSelectDataName', this._get(selectedNodeInfo, 'cfModelAttribute.defaultSelectDataName', ''));
      this.$set(this.dialogModel, 'isSupportMixPack', this._get(selectedNodeInfo, 'cfModelAttribute.isSupportMixPack', false));
      this.$set(this.dialogModel, 'mixPackField', this._get(selectedNodeInfo, 'cfModelAttribute.mixPackField', ''));
      this.$set(this.dialogModel, 'chartHeight', this._get(selectedNodeInfo, 'cfModelAttribute.chartHeight', ''));
      this.$set(this.dialogModel, 'chartSourceList', this._get(selectedNodeInfo, 'cfModelAttribute.chartSourceList', []));
      this.$set(this.dialogModel, 'beforeRequestData', this._get(selectedNodeInfo, 'cfModelAttribute.beforeRequestData', []));
      this.$set(this.dialogModel, 'hideFormItemList', this._get(selectedNodeInfo, 'cfModelAttribute.hideFormItemList', []));
      this.$set(this.dialogModel, 'isDefaultHide', this._get(selectedNodeInfo, 'cfModelAttribute.isDefaultHide', []));
      this.$set(this.dialogModel, 'isEnableCache', this._get(selectedNodeInfo, 'cfModelAttribute.isEnableCache', false));
      this.$set(this.dialogModel, 'isTogetherVerifyDuplicate', this._get(selectedNodeInfo, 'cfModelAttribute.isTogetherVerifyDuplicate', false));
      this.$set(this.dialogModel, 'isCachePrintInfo', this._get(selectedNodeInfo, 'cfModelAttribute.isCachePrintInfo', false));

      if (dataType === 'check-step') {
        let $stepContent = $dragItem.find('.step-content');
        $stepContent.empty();
        let $ps = '';
        this._forEach(this.dialogModel.checkStepList, (item) => {
          $ps += `<p class="step-desc"><i class="iconfont icon-big-circle"></i>${item.name}</p>`;
        });
        $stepContent.append($ps);
      }

      // if (dataType === 'picture') {
      //     setTimeout(() => {
      //         console.log($('.fileinput .fileinput-preview.thumbnail'));
      //         $('.fileinput .fileinput-preview.thumbnail').html(`<img alt="图片地址路径错误"  src="${this.dialogModel.pictureUrl}">`);
      //     }, 50);
      // }

      //绑定动作信息，目前只显示一个
      let selectedNodeActionInfo = this._get(selectedNodeInfo, 'cfActionList[0]', {});
      this.$set(this.dialogModel, 'actionType', this._get(selectedNodeActionInfo, 'actionType', ''));
      let commonDataList = this._get(selectedNodeActionInfo, 'commonDataList', []);
      if (commonDataList.length === 0) {
        this.selectedNodeActionList = [
          {
            actionType: this.dialogModel.actionType,
            commonDataList: []
          }
        ];
      } else {
        // 先判断响应数组里的序号是否赋值，若无赋值则显示空
        commonDataList = this._map(commonDataList, (commonDataItem) => {
          if (!commonDataItem.sequence) {
            commonDataItem.sequence = '';
          }
          return commonDataItem;
        });
        this.selectedNodeActionList = [
          {
            actionType: this.dialogModel.actionType,
            commonDataList: commonDataList
          }
        ];
      }
    },

    /**
     * 设置全局数组中的单个值
     * @param name
     * @param value
     */
    setSingleModelValue(name, value) {
      this._forEach(this.stationUiList, (dragItem) => {
        let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
        if (this.dialogModel.id === dragItemGuid) {
          dragItem.cfModelAttribute[name] = value;
        }
      });
    },

    /**
     * 全屏预览工站作业界面
     */
    showPreviewModal() {
      $('#designer_div').find('.dialog-div').empty();
      let $designerDivStr = $('.dialog-div').html();
      $('#designer_div').find('.dialog-div').append($designerDivStr);
      $('#designer_div')
        .find('.designer-item')
        .each((index, item) => {
          $(item).removeAttr('style');
        });
      $('#designer_div')
        .find('.drag-form-group')
        .each((index, item) => {
          $(item).find('input').removeAttr('readonly');
        });

      $('#designer_div .step-content').find('.step-desc').eq(0).addClass('text-success');
      $('#designer_div .step-content').find('.fa').eq(0).removeClass('fa-circle-o').addClass('fa-check-circle-o');

      $('#designer_div .step-content').find('.step-desc').eq(1).addClass('text-danger');
      $('#designer_div .step-content').find('.fa').eq(1).removeClass('fa-circle-o').addClass('fa-times-circle-o');

      //获取要展示全屏的元素
      var doc = window.document;
      let docEl = document.getElementById('designer_div');
      let fullscreenFunc = docEl.requestFullscreen;
      let cancelFullScreen = doc.exitFullscreen;

      // 设定docuement 的参数
      if (!this.isShowPreview) {
        ['mozRequestFullScreen', 'msRequestFullscreen', 'webkitRequestFullScreen'].forEach(function (req) {
          fullscreenFunc = fullscreenFunc || docEl[req];
        });
        //把全屏展示的内容 通过call 改变this指向
        fullscreenFunc.call(docEl);
        this.isShowPreview = true;
      } else {
        ['mozCancelFullScreen', 'webkitExitFullscreen', 'msExitFullscreen'].forEach(function (req) {
          cancelFullScreen = cancelFullScreen || doc[req];
        });
        cancelFullScreen.call(doc);
        this.isShowPreview = false;
      }

      docEl.addEventListener('fullscreenchange', () => {
        if (document.fullscreenElement) {
          $('#designer_div').show();
          this.isShowPreview = true;
        } else {
          // console.log('退出全屏')
          $('#designer_div').hide();
          this.isShowPreview = false;
        }
      });
    },

    /**
     * 返回工站配置
     */
    onReturn() {
      if (this.$route.query.type === 'station') {
        this.$router.replace('/product/dialogModel-manage/station-manage');
      } else {
        this.$router.replace('/cloud/cloud_station-template-manage');
      }
    },

    /**
     * 提交工站信息
     */
    onSubmit() {
      if (!this.dialogInfo.zhCnName) {
        this.dialogModel = {};
        $('.drag-item').removeClass('active');
        this.$confirm('请输入弹窗名称！', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          focusInput('zhCnName');
        });
        return;
      }

      //检查UI设计组件
      let checkResult = this.onCheckStationUi();
      if (!checkResult) {
        return;
      }

      let verifySequence = false;
      this._forEach(this.stationInitRequestList, (element) => {
        if (element.sequence && element.sequence <= 0) {
          verifySequence = true;
        }
      });

      this._forEach(this.stationUiList, (element) => {
        if (element.cfActionList[0]) {
          this._forEach(element.cfActionList[0].commonDataList, (commonDataItem) => {
            if (commonDataItem.sequence && commonDataItem.sequence <= 0) {
              verifySequence = true;
            }
          });
        }
      });

      if (verifySequence) {
        this.$confirm('API响应的序号不能小于等于0', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {});
        return;
      }

      //移除所有拖拽组件的高亮状态
      $('.drag-item').removeClass('active');
      $('.drag-item').removeClass('error');
      //移除所有容器的style高度样式
      $('.designer-item').removeAttr('style');
      //移除所有td的高亮状态
      $('.table-report').find('td').removeClass('tdActive');
      $('.table-report').attr('title', '');

      let $designerDivStr = $('.dialog-div').html();
      console.log($designerDivStr);
      console.log(this.stationUiList);
      let stationUiJson = JSON.stringify(this.stationUiList);
      let option = {
        initRequestList: this.stationInitRequestList,
        initInputName: this.dialogInfo.initInputName
      };
      let type = 'STATION';
      switch (this.type) {
        case 'function':
          type = 'FUNCTION';
          break;
        default:
          break;
      }
      let paramMap = {
        clientType: this.dialogInfo.clientType,
        type: this.dialogInfo.stationType,
        enabled: true,
        name: this.dialogInfo.zhCnName,
        imgsrc: this.dialogInfo.imgsrc,
        remark: this.dialogInfo.zhCnContent, //备注
        options: JSON.stringify(option),
        uiPage: $designerDivStr, //工站UI界面HTML
        uiJson: stationUiJson //工站UI组件数据源
      };
      this.$emit('dialogUiConfig', paramMap);
    },

    /**
     * 检查组件是否配置完整
     */
    onCheckStationUi() {
      if (this.stationUiList.length === 0) {
        this.$confirm('未拖拽出任何组件', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {});
        return;
      }
      //查询出未配置组件名称以及字段名称的组件
      let validDragItem = this._find(this.stationUiList, (dragItem) => {
        let dragItemDataType = this._get(dragItem, 'cfModelAttribute.dataType', '');
        let labelName = this._get(dragItem, 'cfModelAttribute.labelName', '');
        let field = this._get(dragItem, 'cfModelAttribute.field', '');
        let dataSource = this._get(dragItem, 'cfModelAttribute.dataSource', []);
        //未配置组件名称
        if (!labelName) {
          return dragItem;
        }
        //未配置字段名称
        if (dragItemDataType !== 'border-title' && dragItemDataType !== 'button') {
          if (!field) {
            return dragItem;
          }
        }
        //单选按钮组件未配置数据源
        if (dragItemDataType === 'radio' && dataSource.length === 0) {
          return dragItem;
        }
        //配置了动作未配置响应 || 配置了响应未配置动作
        let actionType = this._get(dragItem, 'cfActionList[0].actionType', '');
        let commonDataId = this._get(dragItem, 'cfActionList[0].commonDataList[0].id', '');
        if ((actionType && !commonDataId) || (!actionType && commonDataId)) {
          return dragItem;
        }
        //载具组件未配置载具类型
        if (dragItemDataType === 'vehicle' && !this._get(dragItem, 'cfModelAttribute.vehicle', '')) {
          return dragItem;
        }
      });

      //若存在则有信息未配置完全，则对应提示错误信息
      if (validDragItem) {
        let dragItemCfModelAttribute = this._get(validDragItem, 'cfModelAttribute', {});
        let dragItemDataType = this._get(validDragItem, 'cfModelAttribute.dataType', '');
        let dataSource = this._get(validDragItem, 'cfModelAttribute.dataSource', []);
        let $dragItem = $(`#${dragItemCfModelAttribute.id}`);

        $('.drag-item').removeClass('active');
        $('.drag-item').removeClass('error');
        $dragItem.addClass('active');
        $dragItem.addClass('error');
        $('.col_content').removeClass('active');
        $dragItem.parents('.col_content').addClass('active');
        this.setModelValue(dragItemCfModelAttribute.id);
        if (
          dragItemCfModelAttribute.dataType != 'qrcode' &&
          dragItemCfModelAttribute.dataType != 'chart' &&
          dragItemCfModelAttribute.dataType != 'picture' &&
          dragItemCfModelAttribute.dataType != 'hidebtn' &&
          !dragItemCfModelAttribute.labelName
        ) {
          this.$confirm('请输入组件名称！', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            focusInput('labelName');
          });
          return false;
        }
        if (
          dragItemCfModelAttribute.dataType != 'qrcode' &&
          dragItemCfModelAttribute.dataType != 'chart' &&
          dragItemCfModelAttribute.dataType != 'picture' &&
          dragItemCfModelAttribute.dataType != 'hidebtn' &&
          !dragItemCfModelAttribute.field
        ) {
          this.$confirm('请输入组件字段名称！', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            focusInput('field');
          });
          return false;
        }

        //单选按钮组件未配置数据源
        // if (dragItemDataType === 'radio' && dataSource.length === 0) {
        //     this.layerMsg('请配置单选按钮的数据源！', null);
        //     return false;
        // }
        let actionType = this._get(validDragItem, 'cfActionList[0].actionType', '');
        let commonDataId = this._get(validDragItem, 'cfActionList[0].commonDataList[0].id', '');
        // if (actionType && !commonDataId) {
        //     this.$confirm('组件选择了动作但是未添加相应，请检查后再进行保存', '提示', {
        //         confirmButtonText: '确定',
        //         cancelButtonText: '取消',
        //         type: 'warning'
        //     }).then(() => {
        //         focusInput('commonDataName');
        //     });
        //     return false;
        // }
        if (commonDataId && !actionType) {
          this.$confirm('组件添加了响应但是未选择动作，请检查后再进行保存', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            focusInput('commonDataName');
          });
          return false;
        }
        if (dragItemDataType === 'vehicle' && !this._get(validDragItem, 'cfModelAttribute.vehicleType', '')) {
          this.$confirm('请选择载具类型！', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            focusInput('vehicleType');
          });
          return false;
        }
      }
      //检查组件名称是否重复
      var newArray = this.stationUiList.sort();
      let nameIsRepeat = false;
      let labelNameRepeatArray;
      let fieldIsRepeat = false;
      let fieldRepeatArray;
      for (var i = 0; i < this.stationUiList.length; i++) {
        let labelNameArray = this._filter(newArray, (item) => {
          return item.cfModelAttribute.labelName === this.stationUiList[i].cfModelAttribute.labelName;
        });
        let fieldArray = this._filter(newArray, (item) => {
          if (this.stationUiList[i].cfModelAttribute.field) {
            return (
              item.cfModelAttribute.field === this.stationUiList[i].cfModelAttribute.field &&
              item.cfModelAttribute.dataType !== 'button' &&
              this.stationUiList[i].cfModelAttribute.dataType !== 'button'
            );
          }
        });
        if (labelNameArray.length > 1) {
          nameIsRepeat = true;
          labelNameRepeatArray = labelNameArray;
        }
        if (this._compact(fieldArray).length > 1) {
          fieldIsRepeat = true;
          fieldRepeatArray = this._compact(fieldArray);
        }
      }
      // if (nameIsRepeat) {
      //     let repeatObj = this._get(labelNameRepeatArray, '[1].cfModelAttribute', {});
      //     $('.drag-item').removeClass('active');
      //     $('.drag-item').removeClass('error');
      //     $('.col_content').removeClass('active');
      //     this._forEach(labelNameRepeatArray, (item) => {
      //         var $dragItem = $(`#${item.cfModelAttribute.id}`);
      //         $dragItem.addClass('active');
      //         $dragItem.addClass('error');
      //         $dragItem.parents('.col_content').addClass('active');
      //     });
      //     this.setModelValue(repeatObj.id);
      //     this.$confirm(`组件名称 ${repeatObj.labelName} 重复`, '提示', {
      //         confirmButtonText: '确定',
      //         cancelButtonText: '取消',
      //         type: 'warning'
      //     }).then(() => {
      //         focusInput('labelName');
      //     });
      //     return false;
      // }
      if (fieldIsRepeat) {
        let repeatObj = this._get(fieldRepeatArray, '[1].cfModelAttribute', {});
        $('.drag-item').removeClass('active');
        $('.drag-item').removeClass('error');
        $('.col_content').removeClass('active');
        this._forEach(fieldRepeatArray, (item) => {
          var $dragItem = $(`#${item.cfModelAttribute.id}`);
          $dragItem.addClass('active');
          $dragItem.addClass('error');
          $dragItem.parents('.col_content').addClass('active');
        });
        this.setModelValue(repeatObj.id);
        this.$confirm(`组件字段 ${repeatObj.labelName} 重复`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          focusInput('field');
        });
        return false;
      }
      // toastr.success('恭喜你，工站配置无误！');
      return true;
    },

    /**
     * 选择默认的工站界面
     */
    stationuiTypeChange() {
      this.getStationTemplateInfo(this.stationuiType);
      // switch (this.stationuiType) {
      //     case 'OVERSTATION':
      //         this.showDefaultStationUi('OVERSTATION');
      //         break;
      //     case 'TIMESHEET':
      //         this.showDefaultStationUi('TIMESHEET');
      //         break;
      //     case 'TEST':
      //         this.showDefaultStationUi('TEST');
      //         break;
      //     case 'AGING':
      //         this.showDefaultStationUi('AGING');
      //         break;
      //     case 'PACKING':
      //         this.showDefaultStationUi('PACKING');
      //         break;
      //     case 'ASSEMBLY':
      //         this.showDefaultStationUi('ASSEMBLY');
      //         break;
      //     case 'FEEDING':
      //         this.showDefaultStationUi('FEEDING');
      //         break;
      //     default:
      //         break;
      // }
    },

    /**
     * 展示默认的工站界面
     */
    showDefaultStationUi(type) {
      $('.dialog-div').empty();
      let stationUiPage = '';
      let stationUiJson = [];
      let stationInitRequestList = [];
      let initInputName = '';
      if (this.type === 'station') {
        switch (type) {
          case 'OVERSTATION':
            this.dialogInfo.zhCnName = '过站工站';
            this.dialogInfo.stationType = 'OVERSTATION';
            this.dialogInfo.imgsrc = '/img/flow-design/过站.png';
            stationUiPage = DefaultStationUiData.getCrossStationUi().stationUiPage;
            stationUiJson = DefaultStationUiData.getCrossStationUi().stationUiJson;
            stationInitRequestList = DefaultStationUiData.getCrossStationUi().stationInitRequestList;
            initInputName = DefaultStationUiData.getCrossStationUi().initInputName;
            break;
          case 'ASSEMBLY':
            this.dialogInfo.zhCnName = '组装工站';
            this.dialogInfo.stationType = 'ASSEMBLY';
            this.dialogInfo.imgsrc = '/img/flow-design/维修.png';
            stationUiPage = DefaultStationUiData.getAssemblyUi().stationUiPage;
            stationUiJson = DefaultStationUiData.getAssemblyUi().stationUiJson;
            stationInitRequestList = DefaultStationUiData.getAssemblyUi().stationInitRequestList;
            initInputName = DefaultStationUiData.getAssemblyUi().initInputName;
            break;
          case 'TEST':
            this.dialogInfo.zhCnName = '测试工站';
            this.dialogInfo.stationType = 'TEST';
            this.dialogInfo.imgsrc = '/img/flow-design/测试.png';
            stationUiPage = DefaultStationUiData.getTestUi().stationUiPage;
            stationUiJson = DefaultStationUiData.getTestUi().stationUiJson;
            stationInitRequestList = DefaultStationUiData.getTestUi().stationInitRequestList;
            initInputName = DefaultStationUiData.getTestUi().initInputName;
            break;
          case 'PACKING':
            this.dialogInfo.zhCnName = '包装工站';
            this.dialogInfo.stationType = 'PACKING';
            this.dialogInfo.imgsrc = '/img/flow-design/在线外包装.png';
            stationUiPage = DefaultStationUiData.getInPackUi().stationUiPage;
            stationUiJson = DefaultStationUiData.getInPackUi().stationUiJson;
            stationInitRequestList = DefaultStationUiData.getInPackUi().stationInitRequestList;
            initInputName = DefaultStationUiData.getInPackUi().initInputName;
            break;
          case 'AGING':
            this.dialogInfo.zhCnName = '老化工站';
            this.dialogInfo.stationType = 'AGING';
            this.dialogInfo.imgsrc = '/img/flow-design/老化.png';
            stationUiPage = DefaultStationUiData.getAgingUi().stationUiPage;
            stationUiJson = DefaultStationUiData.getAgingUi().stationUiJson;
            stationInitRequestList = DefaultStationUiData.getAgingUi().stationInitRequestList;
            initInputName = DefaultStationUiData.getAgingUi().initInputName;
            break;
          case 'TIMESHEET':
            this.dialogInfo.zhCnName = '报工工站';
            this.dialogInfo.stationType = 'TIMESHEET';
            this.dialogInfo.imgsrc = '/img/flow-design/报工.png';
            stationUiPage = DefaultStationUiData.getEntryUi().stationUiPage;
            stationUiJson = DefaultStationUiData.getEntryUi().stationUiJson;
            stationInitRequestList = DefaultStationUiData.getEntryUi().stationInitRequestList;
            initInputName = DefaultStationUiData.getEntryUi().initInputName;
            break;
          case 'FEEDING':
            this.dialogInfo.zhCnName = '上料工站';
            this.dialogInfo.stationType = 'FEEDING';
            this.dialogInfo.imgsrc = '/img/flow-design/组装.png';
            stationUiPage = DefaultStationUiData.getFeedingUi().stationUiPage;
            stationUiJson = DefaultStationUiData.getFeedingUi().stationUiJson;
            stationInitRequestList = DefaultStationUiData.getFeedingUi().stationInitRequestList;
            initInputName = DefaultStationUiData.getFeedingUi().initInputName;
            break;
          default:
            break;
        }
      } else if (this.type === 'function') {
        switch (type) {
          case 'getSigleUi':
            stationUiPage = DefaultFunctionUiData.getSigleUi().stationUiPage;
            stationUiJson = DefaultFunctionUiData.getSigleUi().stationUiJson;
            stationInitRequestList = DefaultFunctionUiData.getSigleUi().stationInitRequestList;
            initInputName = DefaultFunctionUiData.getSigleUi().initInputName;
            break;
          case 'getSigleUiWithTable':
            stationUiPage = DefaultFunctionUiData.getSigleUiWithTable().stationUiPage;
            stationUiJson = DefaultFunctionUiData.getSigleUiWithTable().stationUiJson;
            stationInitRequestList = DefaultFunctionUiData.getSigleUiWithTable().stationInitRequestList;
            initInputName = DefaultFunctionUiData.getSigleUiWithTable().initInputName;
            break;
          default:
            break;
        }
      }
      $('.dialog-div').append(stationUiPage);
      //工站初始加载
      this.stationInitRequestList = stationInitRequestList;
      this.dialogInfo.initInputName = initInputName;
      this.stationUiList = stationUiJson;
      //赋值默认值
      this._forEach(this.stationUiList, (item) => {
        let selectedNodeDataType = this._get(item, 'cfModelAttribute.dataType', '');
        let selectedNodeDataId = this._get(item, 'cfModelAttribute.id', '');
        let $dragItem = $(`#${selectedNodeDataId}`);
        let dataSource = this._get(item, 'cfModelAttribute.dataSource', []);
        if (selectedNodeDataType === 'radio') {
          //单选框赋默认值
          let valueObj = this._find(dataSource, {
            key: this._get(item, 'cfModelAttribute.defaultValue', '')
          });
          let defaultValue = this._get(dataSource, '[0].key', '');
          if (valueObj) {
            $dragItem.find('input[value=' + this._get(item, 'cfModelAttribute.defaultValue', '') + ']').prop('checked', true);
          } else {
            $dragItem.find('input[value=' + defaultValue + ']').prop('checked', true);
          }
        } else if (selectedNodeDataType === 'select') {
          //下拉框赋默认值
          let valueObj = this._find(dataSource, {
            optionField: this._get(item, 'cfModelAttribute.defaultValue', '')
          });
          if (valueObj) {
            $dragItem.find('select').val(this.dialogModel.defaultValue);
          } else {
            let defaultValue = this._get(dataSource, '[0].optionField', '');
            $dragItem.find('select').val(defaultValue);
          }
        }
      });
    },

    /**
     * 获取当前工站界面中所有可输入类型的输入框
     */
    turnToInputNameClick() {
      this.inputComList = this._map(this.stationUiList, (item) => {
        let selectedNodeDataType = this._get(item, 'cfModelAttribute.dataType', '');
        if (
          selectedNodeDataType === 'input' ||
          selectedNodeDataType === 'textarea' ||
          selectedNodeDataType === 'vehicle' ||
          (selectedNodeDataType === 'select-data' && item.cfModelAttribute.isDisabled === 'false') ||
          selectedNodeDataType === 'input-checkbox'
        ) {
          return {
            field: this._get(item, 'cfModelAttribute.field', ''),
            labelName: this._get(item, 'cfModelAttribute.labelName', '')
          };
        }
      });
      console.log(this.inputComList);
      this.inputComList = this._compact(this.inputComList);
      let recordItemList = $('#recordItemList').find('.recordItem');
      this._forEach(recordItemList, (item) => {
        let label = $($(item).find('.drag-item-text')).text();
        let value = $($(item).find('input')).attr('name');
        this.inputComList.push({ labelName: label, field: value });
      });
      let extendedFieldsList = $('#extendedFieldsList').find('.extendedFields');
      this._forEach(extendedFieldsList, (item) => {
        let label = $($(item).find('.drag-item-text')).text();
        let value = $($(item).find('input')).attr('name');
        this.inputComList.push({ labelName: label, field: value });
      });

      this.displayOrHideModulesList = [];
      this._forEach(this.stationUiList, (item) => {
        let selectedNodeDataType = this._get(item, 'cfModelAttribute.dataType', '');
        if (selectedNodeDataType === 'border-title') {
          this.displayOrHideModulesList.push({
            field: this._get(item, 'cfModelAttribute.id', ''),
            labelName: this._get(item, 'cfModelAttribute.labelName', '')
          });
        }
      });
    },

    /**
     * 切换工站类型
     */
    stationTypeChange() {
      let dialogInfo = this._find(this.stationTypeList, {
        code: this.dialogInfo.stationType
      });
      this.dialogInfo.stationTypeName = this._get(dialogInfo, 'name', '');
    },

    /**
     * 打开选择图标模态框组件
     */
    openStationIconModal() {
      this.showIconImgDialog = true;
    },

    /**
     * 双击选择图标
     * @param {*} stationItem
     */
    dblclick(stationItem) {
      this.showIconImgDialog = false;
      this.dialogInfo.imgsrc = stationItem;
    },

    /**
     * 移除工站图标
     */
    removeStationIcon() {
      this.dialogInfo.imgsrc = '';
    },

    /**
     * 提交前 弹窗
     */
    openDialogConfigModal() {
      if (!this.dialogModel.actionType) {
        this.$confirm(`请先选择动作！`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {});
        return;
      }
      this.showBeforeRequestModal = true;
      console.log(this.dialogModel.beforeRequestData);
      this.beforeRequestData = this.dialogModel.beforeRequestData;
    },

    beforeRequestRowSave(form, done) {
      done();
    },

    beforeRequestRowUpdate(form, done) {
      done();
    },

    beforeRequestRowDel(row, index) {
      this.beforeRequestData.splice(index, 1);
    },

    /**
     * 提交前 弹窗内容保存
     */
    onBeforeRequestSubmit() {
      this.dialogModel.beforeRequestData = this.beforeRequestData;
      this.showBeforeRequestModal = false;
      this.setSingleModelValue('beforeRequestData', this.dialogModel.beforeRequestData);
    },

    /**
     * 添加响应(打开通过数据API模态框)
     */
    openCommonDataModal(type, index) {
      this.responseType = type;
      this.responseIndex = index;
      if (this.responseType === 'dragItem') {
        if (!this.dialogModel.actionType) {
          this.$confirm(`请先选择动作！`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {});
          return;
        }
      }
      if (this.responseType === 'apiResponse') {
        this.modalName = 'apiResponseDataModal';
        this.$refs.commonModalTemplate.showModal();
        this.tableOption = {
          modalTitle: '选择API响应(双击进行选择)',
          url: '/api/mes-product/apaas/api/get-operation-api?apiType=OPERATION',
          isPage: true,
          rowSelectionType: 'single',
          columnDefs: [
            {
              label: 'API名称',
              prop: 'zhCnName',
              searchLabelWidth: 100,
              search: true
            },
            {
              label: 'API编码',
              prop: 'code',
              searchLabelWidth: 100,
              search: true
            },
            {
              label: '数据源链接',
              prop: 'url'
            },
            {
              label: 'API类型',
              prop: 'apiType',
              dicData: [
                //可做返回类型的转换
                {
                  label: '查询类',
                  value: 'QUERY'
                },
                {
                  label: '操作类',
                  value: 'OPERATION'
                }
              ]
            },
            {
              label: '备注',
              prop: 'zhCnContent'
            }
          ]
        };
      } else {
        this.modalName = 'commonDataModal';
        this.$refs.commonModalTemplate.showModal();
        this.tableOption = {
          modalTitle: '选择API响应(双击进行选择)',
          url: '/api/mes-product/apaas/api/page',
          isPage: true,
          rowSelectionType: 'single',
          columnDefs: [
            {
              label: 'API名称',
              prop: 'zhCnName',
              searchLabelWidth: 100,
              search: true
            },
            {
              label: 'API编码',
              prop: 'code',
              searchLabelWidth: 100,
              search: true
            },
            {
              label: '数据源链接',
              prop: 'url'
            },
            {
              label: 'API类型',
              prop: 'apiType',
              dicData: [
                //可做返回类型的转换
                {
                  label: '查询类',
                  value: 'QUERY'
                },
                {
                  label: '操作类',
                  value: 'OPERATION'
                }
              ]
            },
            {
              label: '备注',
              prop: 'zhCnContent'
            }
          ]
        };
      }
    },

    openOptionListApiModal() {
      this.modalName = 'optionListApiModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择API响应(双击进行选择)',
        url: '/api/mes-product/apaas/api/page',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: 'API名称',
            prop: 'zhCnName',
            searchLabelWidth: 100,
            search: true
          },
          {
            label: 'API编码',
            prop: 'code',
            searchLabelWidth: 100,
            search: true
          },
          {
            label: '数据源链接',
            prop: 'url'
          },
          {
            label: 'API类型',
            prop: 'apiType',
            dicData: [
              //可做返回类型的转换
              {
                label: '查询类',
                value: 'QUERY'
              },
              {
                label: '操作类',
                value: 'OPERATION'
              }
            ]
          },
          {
            label: '备注',
            prop: 'zhCnContent'
          }
        ]
      };
    },

    /**
     * 模态框表格选中数据返回
     */
    getSelectedRows(data) {
      console.log(data);
      switch (this.modalName) {
        case 'commonDataModal':
          // 数据联通的传递方式需要解决,点击添加响应后弹出上面的内容进行选择,选择后的数据获取在下面获取,最终以全局变量处理
          if (this.responseType === 'station') {
            // 如果是初始加载的响应的处理
            if (this.responseIndex !== null) {
              this._forEach(this.stationInitRequestList, (requestItem, requestItemIndex) => {
                if (requestItemIndex === this.responseIndex) {
                  if (data.apiType === 'QUERY') {
                    data['failDoList'] = [];
                    data['sequence'] = '';
                    data['successDoList'] = this._map(JSON.parse(data.returnFields), (item) => {
                      return {
                        componentField: item.fieldAlias ? item.fieldAlias : getHump(item.field),
                        apiField: item.fieldAlias ? item.fieldAlias : getHump(item.field),
                        mappingApi: item.mappingApi,
                        mappingApiName: item.mappingApiName,
                        fieldNotes: item.fieldNotes
                      };
                    });
                    data['params'] = this._map(JSON.parse(data.paramsJson), (paramsItem) => {
                      paramsItem['mapingCode'] = '';
                      return paramsItem;
                    });
                  } else if (data.apiType === 'OPERATION') {
                    data['successDoList'] = [];
                    data['failDoList'] = [];
                    let paramsList = []; // 重构API传参格式变化,paramMap已经不使用,最终下面的转换和解析出的一样
                    // for (const key in JSON.parse(data.paramsJson)) {
                    //     if (Object.prototype.hasOwnProperty.call(JSON.parse(data.paramsJson), key)) {
                    //         const element = JSON.parse(data.paramsJson)[key];
                    //         paramsList.push({
                    //             code: key,
                    //             value: element,
                    //             mapingCode: ''
                    //         });
                    //     }
                    // }

                    // 这个mapingCode是干嘛的? API参数信息中映射字段

                    this._map(JSON.parse(data.paramsJson), (paramsItem) => {
                      paramsList.push({
                        code: paramsItem.code,
                        value: paramsItem.value,
                        mapingCode: ''
                      });
                    });
                    data['params'] = paramsList;
                  }
                  //重新选择API时需要将当前选中的API中特别数据进行处理，然后将整个对象都替换
                  this.stationInitRequestList[requestItemIndex] = data;
                }
              });
            } else {
              data['condition'] = '';
              data['sequence'] = '';
              if (data.apiType === 'QUERY') {
                data['successDoList'] = [];
                data['successDoList'] = this._map(JSON.parse(data.returnFields), (item) => {
                  return {
                    componentField: item.fieldAlias ? item.fieldAlias : getHump(item.field),
                    apiField: item.fieldAlias ? item.fieldAlias : getHump(item.field),
                    mappingApi: item.mappingApi,
                    mappingApiName: item.mappingApiName,
                    fieldNotes: item.fieldNotes
                  };
                });
                data['params'] = this._map(JSON.parse(data.paramsJson), (paramsItem) => {
                  paramsItem['mapingCode'] = '';
                  return paramsItem;
                });
              } else if (data.apiType === 'OPERATION') {
                data['successDoList'] = [];
                data['failDoList'] = [];
                let paramsList = [];
                this._map(JSON.parse(data.paramsJson), (paramsItem) => {
                  paramsList.push({
                    code: paramsItem.code,
                    value: paramsItem.value,
                    mapingCode: ''
                  });
                });
                // for (const key in data.paramMap) {
                //     if (Object.prototype.hasOwnProperty.call(data.paramMap, key)) {
                //         const element = data.paramMap[key];
                //         paramsList.push({
                //             code: key,
                //             name: element,
                //             mapingCode: ''
                //         });
                //     }
                // }
                data['params'] = paramsList;
              }
              this.stationInitRequestList.push(data);
              this.stationInitRequestList = this._orderBy(this.stationInitRequestList, 'sequence');
            }
          } else {
            // 如果是各个组件的响应如何处理
            let commonDataList = this._get(this.selectedNodeActionList, '[0].commonDataList', []);
            if (this.responseIndex !== null) {
              this._forEach(commonDataList, (requestItem, requestItemIndex) => {
                if (requestItemIndex === this.responseIndex) {
                  data['condition'] = '';
                  data['sequence'] = '';
                  if (data.apiType === 'QUERY') {
                    data['failDoList'] = [];
                    data['successDoList'] = this._map(JSON.parse(data.returnFields), (item) => {
                      return {
                        componentField: item.fieldAlias ? item.fieldAlias : getHump(item.field),
                        apiField: item.fieldAlias ? item.fieldAlias : getHump(item.field),
                        mappingApi: item.mappingApi,
                        mappingApiName: item.mappingApiName,
                        fieldNotes: item.fieldNotes
                      };
                    });
                    data['params'] = this._map(JSON.parse(data.paramsJson), (paramsItem) => {
                      paramsItem['mapingCode'] = '';
                      return paramsItem;
                    });
                  } else if (data.apiType === 'OPERATION') {
                    data['successDoList'] = [];
                    data['failDoList'] = [];
                    let paramsList = [];
                    this._map(JSON.parse(data.paramsJson), (paramsItem) => {
                      paramsList.push({
                        code: paramsItem.code,
                        value: paramsItem.value,
                        mapingCode: ''
                      });
                    });
                    // for (const key in data.paramMap) {
                    //     if (Object.prototype.hasOwnProperty.call(data.paramMap, key)) {
                    //         const element = data.paramMap[key];
                    //         paramsList.push({
                    //             code: key,
                    //             name: element,
                    //             mapingCode: ''
                    //         });
                    //     }
                    // }
                    data['params'] = paramsList;
                  }
                  //重新选择API时需要将当前选中的API中特别数据进行处理，然后将整个对象都替换
                  commonDataList[requestItemIndex] = data;
                }
              });
            } else {
              data['condition'] = '';
              data['sequence'] = '';
              if (data.apiType === 'QUERY') {
                data['successDoList'] = [];
                data['successDoList'] = this._map(JSON.parse(data.returnFields), (item) => {
                  return {
                    componentField: item.fieldAlias ? item.fieldAlias : getHump(item.field),
                    apiField: item.fieldAlias ? item.fieldAlias : getHump(item.field),
                    mappingApi: item.mappingApi,
                    mappingApiName: item.mappingApiName,
                    fieldNotes: item.fieldNotes
                  };
                });
                data['params'] = this._map(JSON.parse(data.paramsJson), (paramsItem) => {
                  paramsItem['mapingCode'] = '';
                  return paramsItem;
                });
              } else if (data.apiType === 'OPERATION') {
                data['successDoList'] = [];
                data['failDoList'] = [];
                let paramsList = [];
                this._map(JSON.parse(data.paramsJson), (paramsItem) => {
                  paramsList.push({
                    code: paramsItem.code,
                    value: paramsItem.value,
                    mapingCode: ''
                  });
                });
                // for (const key in data.paramMap) {
                //     if (Object.prototype.hasOwnProperty.call(data.paramMap, key)) {
                //         const element = data.paramMap[key];
                //         paramsList.push({
                //             code: key,
                //             name: element,
                //             mapingCode: ''
                //         });
                //     }
                // }
                data['params'] = paramsList;
              }
              commonDataList.push(data);
              commonDataList = this._orderBy(commonDataList, 'sequence');
            }
            this.selectedNodeActionList = [
              {
                actionType: this.dialogModel.actionType,
                commonDataList: commonDataList
              }
            ];
            this._forEach(this.stationUiList, (dragItem) => {
              let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
              if (this.dialogModel.id === dragItemGuid) {
                dragItem.cfActionList = [
                  {
                    actionType: this.dialogModel.actionType,
                    commonDataList: commonDataList
                  }
                ];
              }
            });
          }
          break;
        case 'apiResponseDataModal':
          this.dialogModel.checkStepApiId = data.id;
          this.dialogModel.checkStepApiName = data.zhCnName;
          let apiFlowJson = data.apiFlowJson;
          let checkStepList = [];
          if (apiFlowJson) {
            apiFlowJson = JSON.parse(apiFlowJson);
            console.log(apiFlowJson);
            let nodeDataArray = this._get(apiFlowJson, 'nodeDataArray', []);
            this._forEach(nodeDataArray, (item) => {
              if (item.nodeType === 'CHECKER') {
                this._forEach(item.checkItemList, (checkItem) => {
                  checkStepList.push(checkItem);
                });
              }
            });
          }
          this.dialogModel.checkStepList = checkStepList;
          console.log(this.dialogModel.checkStepList);
          let $stepContent = $('#' + this.dialogModel.id).find('.step-content');
          $stepContent.empty();
          let $ps = '';
          this._forEach(this.dialogModel.checkStepList, (item) => {
            $ps += `<p class="step-desc"><i class="iconfont icon-big-circle"></i>${item.name}</p>`;
          });
          $stepContent.append($ps);

          this._forEach(this.stationUiList, (dragItem) => {
            let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
            if (this.dialogModel.id === dragItemGuid) {
              dragItem.cfModelAttribute['checkStepApiId'] = this.dialogModel.checkStepApiId;
              dragItem.cfModelAttribute['checkStepApiName'] = this.dialogModel.checkStepApiName;
              dragItem.cfModelAttribute['checkStepList'] = this.dialogModel.checkStepList;
            }
          });
          break;
        case 'sequenceDefineModal':
          this.dialogModel.defaultSelectDataName = this._get(data, 'name', '');
          this._forEach(this.stationUiList, (dragItem) => {
            let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
            if (this.dialogModel.id === dragItemGuid) {
              dragItem.cfModelAttribute['defaultSelectDataCode'] = this._get(data, 'id', '');
              dragItem.cfModelAttribute['defaultSelectDataName'] = this._get(data, 'name', '');
            }
          });
          break;
        case 'printerModal':
          this.dialogModel.defaultSelectDataName = this._get(data, 'name', '');
          this._forEach(this.stationUiList, (dragItem) => {
            let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
            if (this.dialogModel.id === dragItemGuid) {
              dragItem.cfModelAttribute['defaultSelectDataCode'] = this._get(data, 'id', '');
              dragItem.cfModelAttribute['defaultSelectDataName'] = this._get(data, 'name', '');
            }
          });
          break;
        case 'labelTemplateModal':
          this.dialogModel.defaultSelectDataName = this._get(data, 'fileName', '');
          this._forEach(this.stationUiList, (dragItem) => {
            let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
            if (this.dialogModel.id === dragItemGuid) {
              dragItem.cfModelAttribute['defaultSelectDataCode'] = this._get(data, 'id', '');
              dragItem.cfModelAttribute['defaultSelectDataName'] = this._get(data, 'fileName', '');
            }
          });
          break;
        case 'optionListApiModal':
          this.dialogModel.optionListApi = this._get(data, 'url', '');
          this.setSingleModelValue('optionListApiCode', this._get(data, 'code', ''));
          this.setSingleModelValue('optionListApi', this.dialogModel.optionListApi);
          break;
        default:
          break;
      }
    },

    /**
     * 删除工站的初始加载函数
     * @param index 索引
     */
    removeStationRequestInitItem(index) {
      this.stationInitRequestList.splice(index, 1);
    },

    /**
     * 初始化响应序号输入
     * @param commonData
     * @param index
     */
    saveApiSequence(sequence, index) {
      this._forEach(this.stationInitRequestList, (requestItem, requestItemIndex) => {
        if (requestItemIndex === index) {
          requestItem.sequence = Number(sequence);
        }
      });
      this.stationInitRequestList = this._orderBy(this.stationInitRequestList, 'sequence');
    },
    /**
     * API是否开启定时调用
     */
    isEnableIntervalCallChange(event, index) {
      this.stationInitRequestList[index].isEnableIntervalCall = event;
      if (!event) {
        this.stationInitRequestList[index].IntervalTime = undefined;
      }
    },
    /**
     * API定时调用时间
     */
    saveApiIntervalTime(IntervalTime, index) {
      this.stationInitRequestList[index].IntervalTime = IntervalTime;
    },

    /**
     * 打开设置API响应(参数信息)弹框
     * @param index 响应索引
     */
    openApiParamsModal(type, index) {
      this.requestItemIndex = index;
      this.requestItemType = type;
      this.isSelectParamsRow = false;
      let paramsList = [];
      if (type === 'station') {
        if (this.stationInitRequestList[index].apiType === 'OPERATION') {
          if (JSON.parse(this.stationInitRequestList[index].paramsJson) && JSON.parse(this.stationInitRequestList[index].paramsJson).length > 0) {
            paramsList = JSON.parse(this.stationInitRequestList[index].paramsJson);
          } else {
            this._map(JSON.parse(this.stationInitRequestList[index].paramsJson), (paramsItem) => {
              paramsList.push({
                code: paramsItem.code,
                value: paramsItem.value,
                mapingCode: ''
              });
            });
          }
        } else {
          paramsList = JSON.parse(this.stationInitRequestList[index].paramsJson);
        }
      } else if (type === 'dragItem') {
        let commonDataList = this._get(this.selectedNodeActionList, '[0].commonDataList', []);
        if (commonDataList[index].apiType === 'OPERATION') {
          //操作类参数为对象需要做转换
          if (commonDataList[index].params && commonDataList[index].params.length > 0) {
            paramsList = this._get(commonDataList[index], 'params', []);
          } else {
            for (const key in commonDataList[index].paramMap) {
              if (Object.prototype.hasOwnProperty.call(commonDataList[index].paramMap, key)) {
                const element = commonDataList[index].paramMap[key];
                paramsList.push({
                  code: key,
                  name: element,
                  mapingCode: ''
                });
              }
            }
          }
        } else {
          paramsList = commonDataList[index].params;
        }
      }

      // 调取弹框显示参数信息返回显示 先处理一个弹框显示
      this.showApiDialog = true;
      // 将paramsList的处理放进表格中渲染，对应字段
      this.dataApiParamsMap = paramsList;
      // this.paramsGridOptions.api.setRowData(paramsList);
    },

    /**
     * 移除响应API
     */
    removeCommonDataItem(index) {
      let oldCommonDataList = this._get(this.selectedNodeActionList, '[0].commonDataList', []);
      if (this.dialogModel.actionType) {
        if (oldCommonDataList.length > 1) {
          this.selectedNodeActionList[0].commonDataList.splice(index, 1);
          this._forEach(this.stationUiList, (dragItem) => {
            let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
            if (this.dialogModel.id === dragItemGuid) {
              dragItem.cfActionList = [
                {
                  actionType: this.dialogModel.actionType,
                  commonDataList: this.selectedNodeActionList[0].commonDataList
                }
              ];
            }
          });
        } else {
          this.$confirm('至少保留一个响应！', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {});
        }
      } else {
        this.selectedNodeActionList[0].commonDataList.splice(index, 1);
        this._forEach(this.stationUiList, (dragItem) => {
          let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
          if (this.dialogModel.id === dragItemGuid) {
            dragItem.cfActionList = [
              {
                actionType: this.dialogModel.actionType,
                commonDataList: this.selectedNodeActionList[0].commonDataList
              }
            ];
          }
        });
      }
    },

    /**
     * 属性控件各个值保存与修改
     */
    formKeyUpFunction() {
      let $dragItem = $(`#${this.dialogModel.id}`);
      let selectedNode = this._find(this.stationUiList, (item) => {
        if (this.dialogModel.id === item.cfModelAttribute.id) {
          return true;
        }
      });
      //当类型不等于报告时可以去修改页面上组件的文本标题，因为报告中含有子组件
      if (
        this.dialogModel.dataType !== 'report' &&
        this.dialogModel.dataType !== 'extended-fields' &&
        this.dialogModel.dataType !== 'attribute-copy' &&
        this.dialogModel.dataType !== 'multiple-print'
      ) {
        $dragItem.find('.drag-item-text').text(this.dialogModel.labelName);
      }
      //修改字段信息
      if (
        this.dialogModel.dataType === 'input' ||
        this.dialogModel.dataType === 'select-data' ||
        this.dialogModel.dataType === 'checkbox' ||
        this.dialogModel.dataType === 'radio' ||
        this.dialogModel.dataType === 'fileinput' ||
        this.dialogModel.dataType === 'vehicle' ||
        this.dialogModel.dataType === 'printers' ||
        this.dialogModel.dataType === 'print-label'
      ) {
        $dragItem.find('input').attr('name', this.dialogModel.field);
        $dragItem.find('input').attr('placeholder', this.dialogModel.placeholder);
      } else if (this.dialogModel.dataType === 'info-input') {
        $dragItem.find('input').attr('name', this.dialogModel.field);
        $dragItem.find('input').attr('placeholder', this.dialogModel.placeholder);
      } else if (this.dialogModel.dataType === 'textarea') {
        $dragItem.find('textarea').attr('name', this.dialogModel.field);
        $dragItem.find('textarea').attr('placeholder', this.dialogModel.placeholder);
      } else if (this.dialogModel.dataType === 'select') {
        $dragItem.find('select').attr('name', this.dialogModel.field);
      } else if (this.dialogModel.dataType === 'table') {
        $dragItem.find('tbody').css('height', this.dialogModel.tableHeight + 'px');
      } else if (this.dialogModel.dataType === 'border-title') {
        $dragItem.find('.border-title').css('font-size', this.dialogModel.fontSize + 'px');
      } else if (this.dialogModel.dataType === 'chart') {
        $dragItem.find('iframe').css('height', this.dialogModel.chartHeight + 'px');
      } else if (this.dialogModel.dataType === 'picture') {
        $dragItem.find('img').attr('src', this.dialogModel.pictureUrl);
      } else if (this.dialogModel.dataType === 'input-checkbox') {
        $($dragItem.find('input')[0]).attr('name', this.dialogModel.field);
        $($dragItem.find('input')[0]).attr('placeholder', this.dialogModel.placeholder);
      }

      let cfModelAttribute = {};
      for (const key in this.dialogModel) {
        if (Object.prototype.hasOwnProperty.call(this.dialogModel, key)) {
          const element = this.dialogModel[key];
          cfModelAttribute[key] = element;
        }
      }
      this.stationUiList = this._map(this.stationUiList, (dragItem) => {
        let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
        let selectedNodeId = this._get(selectedNode, 'cfModelAttribute.id', '');
        if (selectedNodeId === dragItemGuid) {
          dragItem = {
            cfModelAttribute: cfModelAttribute,
            cfActionList: this.selectedNodeActionList
          };
        }
        return dragItem;
      });
    },

    /**
     * 正则表达式保存与修改
     */
    regexpKeyUpFunction() {
      this.setSingleModelValue('regexp', this.dialogModel.regexp);
    },

    dataSourceRequestParamKeyUpFunction() {
      this.setSingleModelValue('dataSourceRequestParam', this.dialogModel.dataSourceRequestParam);
    },

    dataSourceFormatKeyUpFunction() {
      this.setSingleModelValue('dataSourceFormat', this.dialogModel.dataSourceFormat);
    },

    /**
     * 默认值属性修改函数
     */
    defaultValueKeyUpFunction() {
      let $dragItem = $(`#${this.dialogModel.id}`);
      let selectedNode = this._find(this.stationUiList, (item) => {
        if (this.dialogModel.id === item.cfModelAttribute.id) {
          return true;
        }
      });
      //修改默认值信息
      if (this.dialogModel.dataType === 'radio') {
        let dataSource = this._get(selectedNode, 'cfModelAttribute.dataSource', []);
        let valueObj = this._find(dataSource, { key: this.dialogModel.defaultValue });
        if (valueObj) {
          $dragItem.find('input[value=' + this.dialogModel.defaultValue + ']').prop('checked', true);
        } else {
          let defaultValue = this._get(dataSource, '[0].key', '');
          $dragItem.find('input[value=' + defaultValue + ']').prop('checked', true);
        }
      } else if (this.dialogModel.dataType === 'checkbox') {
        let dataSource = this._get(selectedNode, 'cfModelAttribute.dataSource', []);
        let valueObj = this._find(dataSource, { key: this.dialogModel.defaultValue });
        if (valueObj) {
          $dragItem.find('input[value=' + this.dialogModel.defaultValue + ']').prop('checked', true);
        } else {
          let defaultValue = this._get(dataSource, '[0].key', '');
          $dragItem.find('input[value=' + defaultValue + ']').prop('checked', true);
        }
      } else if (this.dialogModel.dataType === 'select') {
        //下拉框赋值默认值
        let dataSource = this._get(selectedNode, 'cfModelAttribute.dataSource', []);
        let valueObj = this._find(dataSource, { field: this.dialogModel.defaultValue });
        if (valueObj) {
          $dragItem.find('select').val(this.dialogModel.defaultValue);
        } else {
          let defaultValue = this._get(dataSource, '[0].optionField', '');
          $dragItem.find('select').val(defaultValue);
        }
      } else {
        $dragItem.find('input').val(this.dialogModel.defaultValue);
      }
      this.setSingleModelValue('defaultValue', this.dialogModel.defaultValue);
    },

    /**
     * 默认提示属性修改函数
     */
    defaultTipMessageKeyUpFunction() {
      let $dragItemLabel = $('#' + this.dialogModel.id).children('label');
      if (this.dialogModel.defaultTipMessage) {
        $dragItemLabel.find('.tooltip-icon').remove();
        $dragItemLabel.prepend(`<i class="material-icons tooltip-icon text-gray" title="${this.dialogModel.defaultTipMessage}">help</i>`);
      } else {
        $dragItemLabel.find('.tooltip-icon').remove();
      }
      this.setSingleModelValue('defaultTipMessage', this.dialogModel.defaultTipMessage);
    },

    /**
     * 切换输入框类型
     */
    onChangeInputType(event) {
      let $input = $('#' + this.dialogModel.id).find('input');
      $input.attr('type', event);
      // if (event === 'number') {
      //     $input.attr('step', '0.000001');
      // } else {
      //     $input.attr('step', '');
      // }
      this.setSingleModelValue('inputType', event);
    },

    /**
     * 切换载具类型
     */
    onChangeVehicleType(event) {
      this.setSingleModelValue('vehicleType', event);
    },

    vehicleTypeFieldKeyUpFunction() {
      this.setSingleModelValue('vehicleTypeField', this.dialogModel.vehicleTypeField);
    },

    mixPackFieldKeyUpFunction() {
      this.setSingleModelValue('mixPackField', this.dialogModel.mixPackField);
    },

    /**
     * 切花数据选择类型
     */
    onChangeSelectDataType(event) {
      this.setSingleModelValue('selectDataType', event);
    },

    /**
     * 切换是否必填项
     */
    isRequiredChange(event) {
      let $dragItemLabel = $('#' + this.dialogModel.id).children('label');
      let hasRequiredClass = $dragItemLabel.children('.required').hasClass('required');
      if (this.dialogModel.isRequired === 'true') {
        if (!hasRequiredClass) {
          $dragItemLabel.prepend(`<span class="required text-danger">*</span>`);
        }
      } else {
        $dragItemLabel.find('.required').remove();
      }
      this.setSingleModelValue('isRequired', event);
    },

    /**
     * 切换是否禁用
     */
    isDisabledChange(type, event) {
      let $dragItemLabel;
      if (type === 'textarea') {
        $dragItemLabel = $('#' + this.dialogModel.id).children('textarea');
      } else if (type === 'select-data') {
        $dragItemLabel = $('#' + this.dialogModel.id).find('input');
      }
      if (this.dialogModel.isDisabled === 'true') {
        $dragItemLabel.attr('disabled', 'disabled');
      } else {
        $dragItemLabel.removeAttr('disabled');
      }
      this.setSingleModelValue('isDisabled', event);
    },

    /**
     * 切换是否自动扣减合格数
     */
    isAutoDeductionChange(event) {
      this.setSingleModelValue('isAutoDeduction', event);
    },

    /**
     * 切换是否本地存储字段值
     */
    isLocalStorageChange(event) {
      this.setSingleModelValue('isLocalStorage', event);
    },

    disabledInputNameChange(event) {
      this.setSingleModelValue('disabledInputName', event);
    },
    createQrCodeChange(event) {
      this.setSingleModelValue('createQrCode', event);
    },

    /**
     * 是否隐藏模块
     */
    isHideModuleChange(event) {
      this.setSingleModelValue('isHideModule', event);
    },

    isEnableCacheChange(event) {
      this.setSingleModelValue('isEnableCache', event);
    },

    isTogetherVerifyDuplicateChange(event) {
      this.setSingleModelValue('isTogetherVerifyDuplicate', event);
    },

    /**
     * 是否开启混包
     */
    isSupportMixPackChange(event) {
      this.setSingleModelValue('isSupportMixPack', event);
    },

    /**
     * 图片组件上传
     */
    pictureAvatarSuccess(res, file) {
      this.dialogModel.pictureUrl = URL.createObjectURL(file.raw);
      this.formKeyUpFunction();
    },

    /**
     * 图片组件上传前
     */
    pictureBeforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传图片只能是 jpeg/jpg/png 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    },

    /**
     * 删除图片组件内容
     */
    removepictureUrl() {
      this.dialogModel.pictureUrl = '';
      this.formKeyUpFunction();
    },

    /**
     * 组件的动作切换事件
     */
    actionType() {
      let commonDataList = this._get(this.selectedNodeActionList, '[0].commonDataList', []);
      this._forEach(this.stationUiList, (dragItem) => {
        let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
        if (this.dialogModel.id === dragItemGuid) {
          dragItem.cfModelAttribute['actionType'] = this.dialogModel.actionType;
          dragItem.cfActionList = [
            {
              actionType: this.dialogModel.actionType,
              commonDataList: commonDataList
            }
          ];
        }
      });
    },

    /**
     * 选择成功后跳转输入框事件
     */
    turnToInputNameChange(event) {
      this.setSingleModelValue('turnToInputName', event);
    },

    /**
     * 选择失败后跳转输入框事件
     */
    failTurnToInputNameChange(event) {
      this.setSingleModelValue('failTurnToInputName', event);
    },

    /**
     * 选择无接口时跳转输入框事件
     */
    noApiTurnToInputNameChange(event) {
      this.setSingleModelValue('noApiTurnToInputName', event);
    },

    noApiTurnToInputIsMsgChange(event) {
      this.setSingleModelValue('noApiTurnToInputIsMsg', event);
    },

    displayOrHideModulesChange(event) {
      this.setSingleModelValue('displayOrHideModules', event);
    },

    /**
     * 组件响应触发条件/序号输入
     * @param value
     * @param index
     */
    apiSequenceKeyupFunction(value, index, type) {
      let commonDataList = this.selectedNodeActionList[0].commonDataList;
      this._forEach(commonDataList, (requestItem, requestItemIndex) => {
        if (requestItemIndex === index && type === 'sequence') {
          requestItem.sequence = Number(value);
        }
        if (requestItemIndex === index && type === 'condition') {
          requestItem.condition = value;
        }
      });
      commonDataList = this._orderBy(commonDataList, 'sequence');
      this.selectedNodeActionList = [
        {
          actionType: this.dialogModel.actionType,
          commonDataList: commonDataList
        }
      ];

      this._forEach(this.stationUiList, (dragItem) => {
        let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
        if (this.dialogModel.id === dragItemGuid) {
          dragItem.cfActionList = [
            {
              actionType: this.dialogModel.actionType,
              commonDataList: commonDataList
            }
          ];
        }
      });
    },

    /**
     * API参数信息设置行数据保存
     */
    apiParamsRowSave(form, done) {
      done();
    },

    /**
     * API参数信息设置行数据修改
     */
    apiParamsAddUpdate(form, done) {
      done();
    },

    /**
     * API参数信息设置行数据删除
     */
    apiParamsRowDel(row, index) {
      this.dataApiParamsMap.splice(index, 1);
    },

    onApiParamsSubmit() {
      let paramsList = this.dataApiParamsMap;
      if (this.requestItemType === 'station') {
        this._forEach(this.stationInitRequestList, (requestItem, requestItemIndex) => {
          if (this.requestItemIndex === requestItemIndex) {
            requestItem.params = paramsList;
          }
        });
      }
      if (this.requestItemType === 'dragItem') {
        let commonDataList = this._get(this.selectedNodeActionList, '[0].commonDataList', []);
        this._forEach(commonDataList, (requestItem, requestItemIndex) => {
          if (this.requestItemIndex === requestItemIndex) {
            requestItem.params = paramsList;
          }
        });
        this.selectedNodeActionList = [
          {
            actionType: this.dialogModel.actionType,
            commonDataList: commonDataList
          }
        ];
        this._forEach(this.stationUiList, (dragItem) => {
          let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
          if (this.dialogModel.id === dragItemGuid) {
            dragItem.cfActionList = [
              {
                actionType: this.dialogModel.actionType,
                commonDataList: commonDataList
              }
            ];
          }
        });
      }
      this.showApiDialog = false;
    },

    /**
     * API返回信息设置模态框显示
     */
    openApiResponseModal(type, index) {
      this.showApiResponseModal = true;
      this.apiResponseTabsIndex = '1';
      this.requestItemIndex = index;
      this.requestItemType = type;
      let successDoList = [],
        failDoList = [];
      if (type === 'station') {
        successDoList = this.stationInitRequestList[index].successDoList;
        failDoList = this.stationInitRequestList[index].failDoList;
      } else if (type === 'dragItem') {
        let commonDataList = this._get(this.selectedNodeActionList, '[0].commonDataList', []);
        successDoList = commonDataList[index].successDoList;
        failDoList = commonDataList[index].failDoList;
      }
      this.successDoParamsMap = successDoList;
      this.failDoParamsMap = failDoList;
    },

    /**
     * API返回成功信息设置行数据保存
     */
    successDoParamsRowSave(form, done) {
      done();
    },

    /**
     * API返回成功信息设置行数据修改
     */
    successDoParamsAddUpdate(form, done) {
      done();
    },

    /**
     * API返回成功信息设置行数据删除
     */
    successDoParamsRowDel(row, index) {
      this.successDoParamsMap.splice(index, 1);
    },

    /**
     * API返回失败信息设置行数据保存
     */
    failDoParamsRowSave(form, done) {
      done();
    },

    /**
     * API返回失败信息设置行数据修改
     */
    failDoParamsAddUpdate(form, done) {
      done();
    },

    /**
     * API返回失败信息设置行数据删除
     */
    failDoParamsRowDel(row, index) {
      this.failDoParamsMap.splice(index, 1);
    },

    /**
     * API返回信息保存
     */
    onApiResponseSubmit() {
      let successDoList = this.successDoParamsMap;
      let failDoList = this.failDoParamsMap;
      if (this.requestItemType === 'station') {
        this._forEach(this.stationInitRequestList, (requestItem, requestItemIndex) => {
          if (this.requestItemIndex === requestItemIndex) {
            requestItem.successDoList = successDoList;
            requestItem.failDoList = failDoList;
          }
        });
      }
      if (this.requestItemType === 'dragItem') {
        let commonDataList = this._get(this.selectedNodeActionList, '[0].commonDataList', []);
        this._forEach(commonDataList, (requestItem, requestItemIndex) => {
          if (this.requestItemIndex === requestItemIndex) {
            requestItem.successDoList = successDoList;
            requestItem.failDoList = failDoList;
          }
        });
        this.selectedNodeActionList = [
          {
            actionType: this.dialogModel.actionType,
            commonDataList: commonDataList
          }
        ];
        this._forEach(this.stationUiList, (dragItem) => {
          let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
          if (this.dialogModel.id === dragItemGuid) {
            dragItem.cfActionList = [
              {
                actionType: this.dialogModel.actionType,
                commonDataList: commonDataList
              }
            ];
          }
        });
      }
      this.showApiResponseModal = false;
    },

    /**
     * 打开列编辑模态框
     */
    editColumnInfo() {
      if (this.dialogModel.dataType === 'table') {
        this.showColumnConfigModal = true;
        this.columnConfig = this.dialogModel.columnDefs;
      } else if (this.dialogModel.dataType === 'select-data') {
        this.showModalColumnConfigModal = true;
        this.modalColumnConfig = this.dialogModel.modalColumnDefs;
      }
    },

    /**
     * 列编辑信息设置行数据保存
     */
    columnConfigRowSave(form, done) {
      done();
    },

    /**
     * 列编辑信息设置行数据修改
     */
    columnConfigAddUpdate(form, done) {
      done();
    },

    /**
     * 列编辑信息设置行数据删除
     */
    columnConfigRowDel(row, index) {
      this.columnConfig.splice(index, 1);
    },

    /**
     * 列编辑信息保存
     */
    onColumnConfigSubmit() {
      if (this.dialogModel.dataType === 'table') {
        let newColumnData = [];
        this._forEach(this.columnConfig, (item) => {
          if (item.headerName && item.field) {
            item.field = this._trim(item.field);
            newColumnData.push(item);
          }
        });
        if (newColumnData.length === 0) {
          this.$confirm('请添加表格表头信息！', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {});
          return;
        }
        let columnDefs = '';
        let bodytd = '';
        let $table = $('#' + this.dialogModel.id).find('table');
        $table.find('thead').empty();
        $table.find('tbody').empty();
        this.dialogModel.columnDefs = this._orderBy(newColumnData, 'sequence');
        this._forEach(this.dialogModel.columnDefs, (item) => {
          columnDefs += `<th>${item.headerName}</th>`;
        });
        $table.find('thead').append(columnDefs);
        $table.find('tbody').append(bodytd);
        this.setSingleModelValue('columnDefs', this.dialogModel.columnDefs);
        this.showColumnConfigModal = false;
      } else if (this.dialogModel.dataType === 'select-data') {
        let newColumnData = [];
        this._forEach(this.modalColumnConfig, (item) => {
          if (item.headerName && item.field) {
            item.field = this._trim(item.field);
            newColumnData.push(item);
          }
        });
        if (newColumnData.length === 0) {
          this.$confirm('请添加表格表头信息！', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {});
          return;
        }
        this.dialogModel.modalColumnDefs = this._orderBy(newColumnData, 'sequence');
        this.setSingleModelValue('modalColumnDefs', this.dialogModel.modalColumnDefs);
        this._forEach(this.stationUiList, (dragItem) => {
          let dragItemGuid = this._get(dragItem, 'cfModelAttribute.id', '');
          if (this.dialogModel.id === dragItemGuid) {
            dragItem.cfModelAttribute['modalColumnDefs'] = this.dialogModel.modalColumnDefs;
          }
        });
        this.showModalColumnConfigModal = false;
      }
    },

    /**
     * 弹窗选择列表行保存
     * @param {*} form
     * @param {*} done
     */
    modalColumnConfigRowSave(form, done) {
      done();
    },

    /**
     * 弹窗选择列表行保存
     * @param {*} form
     * @param {*} done
     */
    modalColumnConfigAddUpdate(form, done) {
      done();
    },

    /**
     * 列编辑信息设置行数据删除
     */
    modalColumnConfigRowDel(row, index) {
      this.modalColumnConfig.splice(index, 1);
    },

    /**
     * 设置扩展字段信息
     */
    editExtendedFieldsInfo() {
      this.showExtendedFieldsModal = true;
      let inputComList = [];
      inputComList = this._map(this.stationUiList, (item) => {
        let selectedNodeDataType = this._get(item, 'cfModelAttribute.dataType', '');
        if (
          selectedNodeDataType === 'input' ||
          selectedNodeDataType === 'textarea' ||
          selectedNodeDataType === 'vehicle' ||
          (selectedNodeDataType === 'select-data' && item.cfModelAttribute.isDisabled === 'false')
        ) {
          return {
            label: this._get(item, 'cfModelAttribute.labelName', ''),
            value: this._get(item, 'cfModelAttribute.field', '')
          };
        }
      });
      inputComList = this._compact(inputComList);
      this._forEach(this.dialogModel.extendedFieldsConfig, (item) => {
        if (item.headerName && item.field) {
          inputComList.push({ label: item.headerName, value: item.field });
        }
      });
      let turnToInputName = this.findObject(this.extendedFieldsConfigOption.column, 'turnToInputName');
      turnToInputName.dicData = inputComList;
      console.log(this.dialogModel.extendedFieldsConfig);
      this.extendedFieldsConfig = this.dialogModel.extendedFieldsConfig;
      if (this.extendedFieldsConfig.length === 0) {
        this.dialogModel.extendedFieldsConfig.push({
          sequence: 1,
          headerName: '扩展属性',
          field: 'options1',
          type: 'text',
          dataSource: '',
          turnToInputName: ''
        });
      }
      // if (this.dialogModel.extendedFieldsConfig.length === 0) {
      //     this.extendedFieldsConfig = [];
      //     this.extendedFieldsConfig.push({
      //         sequence: 1,
      //         headerName: '扩展属性',
      //         field: 'options1',
      //         type: 'text',
      //         dataSource: '',
      //         turnToInputName: ''
      //     });
      // } else {
      //     this.extendedFieldsConfig = this._cloneDeep(this.dialogModel.extendedFieldsConfig);
      // }
    },

    extendedFieldsConfigRowSave(form, done) {
      done();
    },

    extendedFieldsConfigUpdate(form, done) {
      done();
    },

    extendedFieldsConfigRowDel(row, index) {
      this.extendedFieldsConfig.splice(index, 1);
    },
    onExtendedFieldsConfigSubmit() {
      let newExtendedFieldsData = [];
      this._forEach(this.extendedFieldsConfig, (item) => {
        if (item.headerName) {
          item.headerName = this._trim(item.headerName);
          newExtendedFieldsData.push(item);
        }
      });
      if (newExtendedFieldsData.length === 0) {
        this.$confirm('请添加扩展属性信息！', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {});
        return;
      }
      let extendedFields = $('#extendedFieldsList');
      this.dialogModel.extendedFieldsConfig = this._orderBy(newExtendedFieldsData, 'sequence');
      console.log(this.dialogModel.extendedFieldsConfig);
      extendedFields.empty();
      this._forEach(this.dialogModel.extendedFieldsConfig, (item, index) => {
        if (item.type === 'select') {
          extendedFields.append(`<div class="extendedFields"><label><span class="drag-item-text">${item.headerName}</span>：</label>
                    <select name="${item.field}" style="border-color: #dcdfe6; border-radius: 4px; padding: 0px 12px; color: #606266; height: 32px;">
                        <option value="" selected="selected">请选择</option>
                    </select></div>`);
        } else {
          extendedFields.append(`<div class="extendedFields"><label><span class="drag-item-text">${item.headerName}</span>：</label>
                    <input class="el-input__inner" type="text" name="${item.field}" autocomplete="off"></div>`);
        }
      });
      this.setSingleModelValue('extendedFields', this.dialogModel.extendedFieldsConfig);
      this.showExtendedFieldsModal = false;
    },
    /**
     * 编辑记录项配置
     */
    editRecordItemInfo() {
      this.showRecordItemModal = true;
      let inputComList = [];
      inputComList = this._map(this.stationUiList, (item) => {
        let selectedNodeDataType = this._get(item, 'cfModelAttribute.dataType', '');
        if (
          selectedNodeDataType === 'input' ||
          selectedNodeDataType === 'textarea' ||
          selectedNodeDataType === 'vehicle' ||
          (selectedNodeDataType === 'select-data' && item.cfModelAttribute.isDisabled === 'false')
        ) {
          return {
            label: this._get(item, 'cfModelAttribute.labelName', ''),
            value: this._get(item, 'cfModelAttribute.field', '')
          };
        }
      });
      inputComList = this._compact(inputComList);
      this._forEach(this.dialogModel.recordItemConfig, (item) => {
        if (item.headerName && item.headerFile) {
          inputComList.push({ label: item.headerName, value: item.headerFile });
        }
      });
      let turnToInputName = this.findObject(this.recordItemConfigOption.column, 'turnToInputName');
      turnToInputName.dicData = inputComList;
      this.recordItemConfig = this.dialogModel.recordItemConfig;
      if (this.recordItemConfig.length === 0) {
        this.dialogModel.recordItemConfig.push({
          sequence: 1,
          headerName: '记录项',
          headerFile: 'reference1',
          isRequired: false,
          turnToInputName: ''
        });
      }
    },
    recordItemConfigRowSave(form, done) {
      done();
    },
    recordItemConfigUpdate(form, done) {
      done();
    },
    recordItemConfigRowDel(row, index) {
      this.recordItemConfig.splice(index, 1);
    },
    /**
     * 保存记录项配置
     */
    onRecordItemConfigSubmit() {
      let newRecordItemData = [];
      this._forEach(this.recordItemConfig, (item) => {
        if (item.headerName) {
          item.headerName = this._trim(item.headerName);
          newRecordItemData.push(item);
        }
      });
      if (newRecordItemData.length === 0) {
        this.$confirm('请添加记录项信息！', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {});
        return;
      }
      let recordItem = $('#recordItemList');
      this.dialogModel.recordItemConfig = this._orderBy(newRecordItemData, 'sequence');
      recordItem.empty();
      this._forEach(this.dialogModel.recordItemConfig, (item, index) => {
        if (item.isRequired) {
          recordItem.append(`<div class="recordItem"><label><span class="required text-danger">*</span><span class="drag-item-text">${item.headerName}</span>：</label>
                    <input class="el-input__inner" type="text" name="${item.headerFile}" autocomplete="off"></div>`);
        } else {
          recordItem.append(`<div class="recordItem"><label><span class="drag-item-text">${item.headerName}</span>：</label>
                    <input class="el-input__inner" type="text" name="${item.headerFile}" autocomplete="off"></div>`);
        }
      });
      this.setSingleModelValue('recordItem', this.dialogModel.recordItemConfig);
      this.showRecordItemModal = false;
    },
    getDisabledInputComList() {
      this.disabledInputComList = [];
      this._forEach(this.stationUiList, (item) => {
        let selectedNodeDataType = this._get(item, 'cfModelAttribute.dataType', '');
        if (selectedNodeDataType === 'info-input') {
          this.disabledInputComList.push({
            labelName: this._get(item, 'cfModelAttribute.labelName', ''),
            field: this._get(item, 'cfModelAttribute.field', '')
          });
        }
      });
    },
    openSelectDataModal() {
      switch (this.dialogModel.selectDataType) {
        case 'sequenceDefine':
          //打开选择包规数量组件框
          this.openSequenceDefineModal();
          break;
        case 'print':
          //打开选择打印机组件
          this.openPrinterModal();
          break;
        case 'labelTemplate':
          // 打开选择打印模板组件
          this.openLabelTemplateModal();
          break;
        default:
          break;
      }
    },
    /**
     * 打开序列号规则选择模态框
     */
    openSequenceDefineModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'sequenceDefineModal';
      this.tableOption = {
        modalTitle: '选择序列号规则（双击进行选择）',
        url: '/api/mes-admin/sequencedefinition/page',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '规则名称',
            prop: 'name',
            search: true
          },
          {
            label: '规则编码',
            prop: 'code',
            search: true
          },
          {
            label: '序列号规则',
            prop: 'sequenceNoFormat',
            labelslot: true
          },
          {
            label: '规则位数',
            prop: 'charactersCount'
          }
        ]
      };
    },
    /**
     * 打开标签模版选择模态框
     */
    openLabelTemplateModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'labelTemplateModal';
      this.tableOption = {
        modalTitle: '选择标签模版（双击进行选择）',
        url: '/api/mes-admin/labeltemplate/page',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '标签名称',
            prop: 'fileName',
            search: true
          },
          {
            label: '标签代码',
            prop: 'code',
            search: true
          },
          {
            label: '缩略图',
            prop: 'thumbnailUrl'
          },
          {
            label: '打印标签',
            prop: 'fileUrl'
          }
        ]
      };
    },
    /**
     * 打开多打印机选择模态框
     */
    openPrinterModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'printerModal';
      this.tableOption = {
        modalTitle: '选择打印机（双击进行选择）',
        url: '/api/mes-product/ems-equipment/page?type=PRINTER',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '打印机名称',
            prop: 'name',
            searchLabelWidth: 130,
            searchSpan: 8,
            search: true
          },
          {
            label: '打印机编码',
            prop: 'code',
            searchLabelWidth: 130,
            searchSpan: 8,
            search: true
          }
        ]
      };
    },
    addChartSourceInfo() {
      this.dialogModel.chartSourceList.push({
        url: '',
        sequence: 0,
        params: []
      });
    },
    removeChartSource(index) {
      this.dialogModel.chartSourceList.splice(index, 1);
    },
    sourceSequenceKeyupFunction(value, index) {
      this.dialogModel.chartSourceList[index].sequence = Number(value);
      this.dialogModel.chartSourceList = this._orderBy(this.dialogModel.chartSourceList, 'sequence');
    },
    /**
     * API参数信息设置行数据保存
     */
    chartSourceParamsRowSave(form, done) {
      done();
    },

    /**
     * API参数信息设置行数据修改
     */
    chartSourceParamsAddUpdate(form, done) {
      done();
    },

    /**
     * API参数信息设置行数据删除
     */
    chartSourceParamsRowDel(row, index) {
      this.chartSourceParamsMap.splice(index, 1);
    },
    openChartSourceParamsModal(index) {
      this.chartSourceIndex = index;
      this.chartSourceParamsMap = this.dialogModel.chartSourceList[index].params;
      this.showChartSourceResponseModal = true;
    },
    onChartSourceResponseSubmit() {
      this.dialogModel.chartSourceList[this.chartSourceIndex].params = this.chartSourceParamsMap;
      this.setSingleModelValue('chartSourceList', this.dialogModel.chartSourceList);
      this.showChartSourceResponseModal = false;
    },
    hideFormItemListChange(event) {
      this.setSingleModelValue('hideFormItemList', event);
    },
    isDefaultHideChange(event) {
      this.setSingleModelValue('isDefaultHide', event);
    },
    isCachePrintInfoChange(event) {
      this.setSingleModelValue('isCachePrintInfo', event);
    }
  }
};
